Hi there,
For a little while now I get an error when running my program in Release mode instead of debug.
When I close the application I get the following error:
Windows has triggered a breakpoint in SFMLTest.exe.
This may be due to a corruption of the heap, which indicates a bug in SFMLTest.exe or any of the DLLs it has loaded.
I already figured out that this happens when I try to delete a pointer in one of my classes.
My main looks about like that:
void main(){
Global::levelMap=new LevelMap("res\\l3.lmap");
...lots of uninteresting code code...
delete Global::levelMap; <-- causing the error
}
The destructor of LevelMap is:
LevelMap::~LevelMap(){
for (int i = 0; i < w; ++i)
delete[] map[i];
..also some other code..
}
It destroys a 2d array. When I comment out this part I don't get the above error anymore.
However:
1) The code doesn't make any problems in Debug mode.
2) I tried to insert a break point into the destructor to check the variables. In Debug mode that's no problem. In Release mode the breakpoint won't trigger. MSVC gives me the following hint about the breakpoint:
The breakpoint will not currently be hit. No executable code is associated with this line.
Possible causes include: prepocessor directives or compiler/linker optimizations.
3) Even though the dtor doesn't seem to be executed at all removing the
delete[] map[i]
also removes the error.
4) Release Mode worked fine a while ago and I haven't changed anything in the Project settings since then.
The error message suggests that some optimization option messes with it. I don't know anything about those though, so I'm pretty much in the dark.
Can anyone help me shed some light on things?