countNumberOfSetBits causes Release build to crash on exit

I never use theese methods countNumberOfSetBits yet their causing problems on Release builds in the plugin wrapper. This gets called on the AudioProcessor destructor
and causes erorrs in this place

int BitArray::countNumberOfSetBits() const throw()
    int total = 0;

    for (int i = (highestBit >> 5) + 1; --i >= 0;)
       ->[error] unsigned int n = values[i];

on debug builds it’s ok.
This is Win7 x64 with VCExpress. I can’t really cactch what’s causing this, i’m not doing anything in the AudioProcessor (i’m starting a project), i have no weird calls no parameters set nothing really happening there.

Well there are two weird things about that…

If you look in the AudioProcessor destructur, that bit of code should only be compiled in the debug build, not release! Have you got debugging enabled or something? (Actually, where it says “#ifdef JUCE_DEBUG”, it should actually be “#if JUCE_DEBUG”)

But even if it’s getting compiled, there’s no reason I can see why it’d crash there unless you’ve managed to overwrite the object’s data somehow… The bitarray class is used all over the place, and is really well-tested. Do its member variables look like sensible values?

i had

#define JUCE_FORCE_DEBUG				1

set this is why in release build it was showing up (i think). but i still don’t understand why. The problem was with endParameterChangeGesture and beginParameterChangeGesture that’s where the BitArray was failing. i chandef the FORCE_DEBUG to 0 and for now it seems to work.

well yes, obviously turning off that line of code would fix the symptoms!

I bet you’ve got your debug settings out of step - if you compiled the .cpp with those debug options turned on, but elsewhere had it turned off when you used the headers, then you might have ended up building objects that don’t actually contain that bitarray at all, and passing them to a destructor that thinks there is a bitarray there!

so could you tell me witch settings to set when in debug and witch in release mode i know there is Force Debug and the JUCE_DEBUG preprocessor flag, should i always set that one and should i set JUCE_RELASE for release builds ?

It’s not that you’re using the wrong macros, but I suspect that you’re not setting them before every file in your build. E.g. if you compiled juce_amalgamated.cpp with the debug flag set, but other files without it, you’d be asking for trouble.