This is the mail archive of the gcc-prs@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]

optimization/1544: Optimzation -O3 breaks exception handling



>Number:         1544
>Category:       optimization
>Synopsis:       Optimzation -O3 breaks exception handling
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 03 14:56:03 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Peter Schmid
>Release:        2.97 20010103 (experimental)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.0-test12 #22 Sun Dec 17 17:24:36 CET 2000 i686 unknown
Architecture: i686
GLIBC 2.1.3
GNU assembler version 2.10.91 (i686-pc-linux-gnu) using BFD version 2.10.1.0.4
g++ -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix
gcc version 2.97 20010103 (experimental)

host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix
>Description:
The following c++ program does not work as expected if the optimization -O3 is
turned on during compilation. Running the program generates a
segmentation fault. If the optimization is reduced to -O2 the program
works as expected.

It did work when the source was compiled by g++-20001220 at the -O3
optimization level. 
>How-To-Repeat:
cat l.C
class A
{
public:
    A() {}
    ~A() {}
};

void f();

int main()
{
    try
    {
        f();
    }
    catch (const char *s) {
    }
}

void f()
{
    A a; 
    throw ("Error");
}
Compiling the program:
g++ -O3 -g -v -o l l.C -save-temps 
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix
gcc version 2.97 20010103 (experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/cpp0 -lang-c++ -D__GNUG__=2 -D__GXX_ABI_VERSION=100 -v -D__GNUC__=2 -D__GNUC_MINOR__=97 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -g -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ l.C l.ii
GNU CPP version 2.97 20010103 (experimental) (cpplib) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/i686-pc-linux-gnu/include/g++-v3
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/include
 /usr/local/i686-pc-linux-gnu/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/cc1plus -fpreprocessed l.ii -quiet -dumpbase l.C -g -O3 -version -fnew-abi -o l.s
GNU C++ version 2.97 20010103 (experimental) (i686-pc-linux-gnu) compiled by GNU C version 2.97 20010103 (experimental).
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o l.o l.s
GNU assembler version 2.10.91 (i686-pc-linux-gnu) using BFD version 2.10.1.0.4
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o l /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/crtbegin.o -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97 -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/../../../../i686-pc-linux-gnu/lib -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/../../.. l.o -lstdc++ -lm -lgcc -lc -lgcc /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/crtend.o /usr/lib/crtn.o

running the program l
peter@kiste:~ > ./l
Aborted (core dumped)

GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) r
Starting program: /home/peter/l 

Program received signal SIGABRT, Aborted.
0x400d4a71 in __kill () from /lib/libc.so.6
(gdb) bt
#0  0x400d4a71 in __kill () from /lib/libc.so.6
#1  0x400d4745 in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x400d5e0f in abort () at ../sysdeps/generic/abort.c:88
#3  0x40047ccb in __default_terminate () from /usr/local/lib/libstdc++.so.3
#4  0x40047cea in __terminate () from /usr/local/lib/libstdc++.so.3
#5  0x40048b79 in throw_helper () from /usr/local/lib/libstdc++.so.3
#6  0x40048cff in __rethrow (index=0x8049844)
   from /usr/local/lib/libstdc++.so.3
#7  0x804872c in _Z1fv () at l.C:5
#8  0x400cea4e in __libc_start_main (main=0x80486d0 <main>, argc=1, 
    argv=0xbffff8ac, init=0x80484fc <_init>, fini=0x804878c <_fini>, 
    rtld_fini=0x4000aa20 <_dl_fini>, stack_end=0xbffff8a4)
    at ../sysdeps/generic/libc-start.c:92


>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:

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