juce_LookAndFeel_V4.h bug (typo?)


#1

juce_LookAndFeel_V4.h, line 60

for (int i = 0; i < numColours; ++i)
palette[i] = c[i];

I believe it should be i++ otherwise c is out of bounds.


#2

No… I think maybe you need to do a bit of learning about how ‘for’ loops work!
http://en.cppreference.com/w/cpp/language/for


#3

(…also you might want to search the juce codebase for “++i” and see the list of places we do this!)


#4

Cppcheck (http://cppcheck.sourceforge.net/) gave me this error:
Array ‘c[1]’ accessed at index 8, which is out of bounds.
and I felt like this is problem without thinking too much.


#5

Well then you’re calling it with the wrong number of arguments. (Though it’s a bit odd that the static_assert would have failed… As you can see, it’s there to make sure that the index can’t be out-of-bounds)


#6

I checked and I’m not calling ColourScheme anywhere in my code. Only time it is called is in Desktop::getDefaultLookAndFeel()

I guess Cppcheck is wrong?


#7

Well, I can’t see how the code could fail if the static_assert has succeeded. Maybe cppcheck doesn’t take that into account.