If you compile the attached file without optimization, it runs fine.  However,
if you compile with -O, then you get:

$ ~/Devel/GCC/local/4.6/bin/g++-4.6 -g -O crash.C -o crash --save-temps
$ ./crash
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted
Interestingly, 4.5 works fine.

The version of 4.6 is revision 164339.

$ ~/Devel/GCC/local/4.6/bin/g++-4.6 -v
Using built-in specs.
COLLECT_GCC=/home/bredelings/Devel/GCC/local/4.6/bin/g++-4.6
COLLECT_LTO_WRAPPER=/home/bredelings/Devel/GCC/local/4.6/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --enable-languages=c,c++,fortran
--prefix=/home/bredelings/Devel/GCC/local/4.6 --enable-shared
--enable-linker-build-id --with-system-zlib --disable-nls --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin
--enable-gold --with-plugin-ld=ld.gold --with-tune=generic --disable-werror
--enable-checking=yes --program-suffix=-4.6
Thread model: posix
gcc version 4.6.0 20100916 (experimental) (GCC) 
The version of 4.5 is:
$ g++-4.5 -v
Using built-in specs.
COLLECT_GCC=/usr/bin/g++-4.5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.5.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.5.1-5'
--with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.5 --enable-shared --enable-multiarch
--enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-plugin --enable-gold --with-plugin-ld=ld.gold --enable-objc-gc
--with-arch-32=i586 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.5.1 (Debian 4.5.1-5) 
The crash seems to result from using the wrong location for SuperModel2::object
in the generated copy constructor.


-- 
           Summary: Incorrect copy constructor generated with -O
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bredelin at ucla dot edu
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699

Reply via email to