Date: Sun, 10 Mar 1996 08:11:24 +0200 (IST) From: Eli Zaretskii To: Michael Schuster Cc: djgpp AT delorie DOT com Subject: Re: Strange Optimization In-Reply-To: Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 8 Mar 1996, Michael Schuster wrote: > I' ve realized a strange(?) behaviour of the optimization switch in GNU > C/C++. > I wrote a program to convert binary files to ASCII files (nothing > _really_exiting, I know) and after a few days, it worked really fine. > > After all I decided to compile with the -O3 option (no error > message at all) but when executing suddenly it chrashed. So I 've > a simple question: Is that what you 'ld call a bug - or is it quite normal? Are you sure it isn't a bug in your program that just surfaces when you compile with optimizations? The -O3 switch enables functions inlining; maybe this triggers some bug that won't show otherwise. Does this happen with -O or -O2? I'd suggest to try to debug the optimized program a bit before you decide that's a compiler bug. You can use the `symify' program to translate the stack trace printed at the time of crash to a list of source filenames and line numbers which will point to the place where it crashed. You can also compile with -O3 *and* -g and debug an optimized program with any debugger--in GCC, these two don't contradict.