This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Including <iostream> affects whether or not program freezes?


On Wed, 09 Jul 2008 03:31:35 +0100, James Gregory wrote:

> 1. Compile with MSVC 7.1, no optimization: my program doesn't freeze 2.
> Compile with MSVC 7.1, with optimization: my program doesn't freeze 3.
> Compile with gcc 4.2.3 (Ubuntu 64 bit), no optimization: my program
> doesn't freeze
> 4. Compile with gcc 4.2.3 (Ubuntu 64 bit), with optimization: my program
> freezes in a particular function 5. Compile with gcc 4.2.3 (Ubuntu 64
> bit), with optimization, and include <iostream> at the top of the file
> where the function which freezes is defined: my program doesn't freeze

You give *way* too little information to even begin to guess what the 
problem might be... but this smells like a classic case of Undefined 
Behaviour - sometimes it appears to work, sometimes it doesn't. I.e. you 
have a bug in your program.

> Debugging this is difficult.

It frequently is ;-) but what other choice do you have? There are tools 
to help (debuggers such as gdb, memory leak checkers such as 
valgrind, ...)

First I would try stripping your program down to a minimal core that 
exhibits the buggy behaviour. Often in doing so you will isolate and 
identify the bug. If not seek help here or in a C (or C++, you don't say 
which language your program is in) forum. You can post minimal code 
demonstrating the problem.

-- 
Lionel B


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]