I've got some strange issue here. For some time I make game with Allegro 5.0.9 in CodeBlocks 12.11 with SEPARATLY downloaded MinGW (the most recent version I belive, coz downloaded it few days ago). So my code compiles and works fine in debug-target, from both CB-side and windows-side. I decided to try it out in release-target today, and here comes the problem. For some reason, it crashes as release-target, doesn't matter if run from CB or directly from windows. My researches showed me it crashes somewhere around drawing or bitmap operations inside my engine class (outside it, ex. in main() it works fine, atleast loading bmp, drawing bmp and fliping display). I'm pretty sure all modules and resources are loaded and initialized, otherwise my app would close itself before any crash could occur.
I mentioned it crashes in my engine class, so it's important (i think so) to mention that's a singleton, and most of code is inside of it (Around 650 lines of code with my formatting). I managed to "find" 2 crash reasons (couldn't go any futher).
First occurs when I try to add object to vector, where object contains ALLEGRO_BITMAP * in constructor, ex.:
CButton::CButton(const float px, const float py, const float w, const float h, const ALLEGRO_COLOR c, const std::string str, ALLEGRO_BITMAP * image) :
PosX(px), PosY(py), Width(px+w), Height(py+h), Color(c), Text(str), Image(image)
and then somewhere
Buttons.push_back(CButton(272,256,256,40,WHITE,"some txt",RESOURCES.GetBitmap("Button_256x40"))); //Buttons is a vector
And that crash throws
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
in console or just crashes. (I found out that bad_alloc is thrown when I try to push_back no more than 2 buttons).
And if I comment out that vector, it just crashes on
al_clear_to_color(al_map_rgb(0,200,255)); // even on al_clear_to_color() !
but it never crashed on
al_flip_display();I know it's hard to guess with such small ammount of information, but maybe anyone have an idea what's wrong?
I'm sorry for not including source code to topic, but I'm not sure where the problem is, so i would have to upload whole 15xx lines, but if someone needs it I can do so. But I warn you, that you'll get a headache coz of how much it sucks.
Thanks in advance.Additional info:
RESOURCES is #define from CResource::GetInstance(), where CResource is another singleton class which holds almost all resources (bitmaps, fonts, samples..).
"just crash" means that "no info" about error is thrown. It looks similar to
And at last my linker settings:
Only diffrences between debug and release are that allegro libs got "-debug" more and there's no "-s" in debug-target