View Single Post
Old Feb 9th, 2008, 8:50 PM   #1
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 641
Rep Power: 4 Jessehk is on a distinguished road
Code Segfaults when compiled with optimizations, doesn't in arbitrary situations

I don't expect people to look through the complicated code that is the problem. I'm mostly looking for some debugging advice because I'm obviously doing something wrong, but at a loss of where to look.

When I compile my code with debugging on, there are no memory errors (checked with valgrind) and everything runs perfectly.

When I compile a "release" mode which includes -O3 and -DNDEBUG, the code segfaults almost immediately. However, when I insert a single output statement in one area of code,

ie,
c++ Syntax (Toggle Plain Text)
  1. std::cout << "Fine" << std::endl;

and recompile (with the same optimizations), everything runs perfectly once again.
Does anyone recognize any symptoms here or have any advice on what class of errors might be causing this bizarre behavior?

Thanks in advance.
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS!
Jessehk is offline   Reply With Quote