juce_LookAndFeel_V4.h bug (typo?)


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.


No… I think maybe you need to do a bit of learning about how ‘for’ loops work!


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


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.


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)


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?


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