User forums > Using Code::Blocks

I found a bug, but i dont know where this bug comes from

(1/2) > >>

When i compile my program normally,  it works 100%. When i check "optimize fully" or "optimize even more" in the build options the program always freezes when i use a certain function in my program.  I cant debug it since debugging doesnt work with optimalisation.

How is this possible, and what can i do to fix this problem?

David Perfors:
I don't know much of optimizing, but I think the program is getting overoptimized. Try to "optimize more". Perhaps that will help...

I have tired a couple of things now, and i noticed that when i turn off optimizing it works 100%, when i turn on the lower optimalisation, it freezes, and @ high optimalisation it crashes :(.

Has this something to do with importing functions from dll's

--- Code: ---
GETMODULEFILENAMEEX GetModuleFileNameExDLL = (GETMODULEFILENAMEEX) GetProcAddress(psapiLib, "GetModuleFileNameExA");
GetModuleFileNameExDLL(hMainProc,mod,fileName,sizeFileName); // <--- this is where somethings goes wrong.

--- End code ---

I dont even know if this is a problem of c::b (not likely IMO), mingw, or my own code  :cry:. Any help on this is really appreciated.

David Perfors:
I don't think C::B has something to do with this, so mingw and your own code are left... Perhaps you should try to search for such bugs at the mingw website, if it is not a problem there, it is your own code :(

I had a similar problem in conjunction with inline assembly once.
-O3 would make my application segfault while -O2 would not, and I did not have a clue why. That is surely a compiler-related issue, though, definitely has nothing to do with code::blocks.
This kind of bug is very annoying because you really get no useful hints. Without a starting point, no one will be able to help you either.

Try this:
go to

There, you find what exactly is turned on by -O, -O2, and -O3.
Now, change to -O or -O2 (whichever still works for you) and add the other options by hand. So you get the very same thing, it still crashes.
Then, take away those extra switches one by one. At some point, it will work. Now you do not have solved the problem, but at least you have a starting point (or your can choose to just leave off one switch).


[0] Message Index

[#] Next page

Go to full version