https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70145
Bug ID: 70145 Summary: g++-5 and g++-6: invalid code generated for -fno-elide-constructors and constexpr array Product: gcc Version: 5.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: robert-gcc at debian dot org Target Milestone: --- Created attachment 37900 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37900&action=edit Simplified test case The attached simplified code gives different results when compiled with -fno-elide-constructors with g++-6: The expected behaviour: /tmp/tst> g++-6 -Wall -Wextra --std=c++1y ./test.cpp -o test /tmp/tst> ./test; echo $? 1 The incorrect output with -fno-elide-constructors: /tmp/tst> g++-6 -Wall -Wextra --std=c++1y -fno-elide-constructors ./test.cpp -o test /tmp/tst> ./test; echo $? 0 The same issue exists in g++-5. The issue is not reproducible in g++-4.9. Versions: * g++-6: Using built-in specs. COLLECT_GCC=g++-6 COLLECT_LTO_WRAPPER=/usr/lib/gcc/i586-linux-gnu/6/lto-wrapper Target: i586-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 6-20160228-1' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-i386/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-i386 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-i386 --with-arch-directory=i386 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-targets=all --enable-multiarch --with-arch-32=i586 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=i586-linux-gnu --host=i586-linux-gnu --target=i586-linux-gnu Thread model: posix gcc version 6.0.0 20160228 (experimental) [trunk revision 233789] (Debian 6-20160228-1) COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=i586' /usr/lib/gcc/i586-linux-gnu/6/cc1plus -quiet -v -imultiarch i386-linux-gnu -D_GNU_SOURCE ./test.cpp -quiet -dumpbase test.cpp -mtune=generic -march=i586 -auxbase test -std=c++11 -version -o /tmp/user/1000/ccOuyw8T.s GNU C++11 (Debian 6-20160228-1) version 6.0.0 20160228 (experimental) [trunk revision 233789] (i586-linux-gnu) compiled by GNU C version 6.0.0 20160228 (experimental) [trunk revision 233789], GMP version 6.1.0, MPFR version 3.1.4-rc1, MPC version 1.0.3, isl version 0.15 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring duplicate directory "/usr/include/i386-linux-gnu/c++/6" ignoring nonexistent directory "/usr/local/include/i386-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/i586-linux-gnu/6/../../../../i586-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/6 /usr/include/i386-linux-gnu/c++/6 /usr/include/c++/6/backward /usr/lib/gcc/i586-linux-gnu/6/include /usr/local/include /usr/lib/gcc/i586-linux-gnu/6/include-fixed /usr/include/i386-linux-gnu /usr/include End of search list. GNU C++11 (Debian 6-20160228-1) version 6.0.0 20160228 (experimental) [trunk revision 233789] (i586-linux-gnu) compiled by GNU C version 6.0.0 20160228 (experimental) [trunk revision 233789], GMP version 6.1.0, MPFR version 3.1.4-rc1, MPC version 1.0.3, isl version 0.15 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 36ae62cc8c2555d6cda1e59f88303dae COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=i586' as -v --32 -o /tmp/user/1000/ccJITulw.o /tmp/user/1000/ccOuyw8T.s GNU assembler version 2.26 (i686-linux-gnu) using BFD version (GNU Binutils for Debian) 2.26 COMPILER_PATH=/usr/lib/gcc/i586-linux-gnu/6/:/usr/lib/gcc/i586-linux-gnu/6/:/usr/lib/gcc/i586-linux-gnu/:/usr/lib/gcc/i586-linux-gnu/6/:/usr/lib/gcc/i586-linux-gnu/ LIBRARY_PATH=/usr/lib/gcc/i586-linux-gnu/6/:/usr/lib/gcc/i586-linux-gnu/6/../../../i386-linux-gnu/:/usr/lib/gcc/i586-linux-gnu/6/../../../../lib/:/lib/i386-linux-gnu/:/lib/../lib/:/usr/lib/i386-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/i586-linux-gnu/6/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=i586' /usr/lib/gcc/i586-linux-gnu/6/collect2 -plugin /usr/lib/gcc/i586-linux-gnu/6/liblto_plugin.so -plugin-opt=/usr/lib/gcc/i586-linux-gnu/6/lto-wrapper -plugin-opt=-fresolution=/tmp/user/1000/ccd7jTD8.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i586-linux-gnu/6/../../../i386-linux-gnu/crt1.o /usr/lib/gcc/i586-linux-gnu/6/../../../i386-linux-gnu/crti.o /usr/lib/gcc/i586-linux-gnu/6/crtbegin.o -L/usr/lib/gcc/i586-linux-gnu/6 -L/usr/lib/gcc/i586-linux-gnu/6/../../../i386-linux-gnu -L/usr/lib/gcc/i586-linux-gnu/6/../../../../lib -L/lib/i386-linux-gnu -L/lib/../lib -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/i586-linux-gnu/6/../../.. /tmp/user/1000/ccJITulw.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i586-linux-gnu/6/crtend.o /usr/lib/gcc/i586-linux-gnu/6/../../../i386-linux-gnu/crtn.o COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=i586' * g++-5: Using built-in specs. COLLECT_GCC=g++-5 COLLECT_LTO_WRAPPER=/usr/lib/gcc/i586-linux-gnu/5/lto-wrapper Target: i586-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 5.3.1-10' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-i386/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-i386 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-i386 --with-arch-directory=i386 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-targets=all --enable-multiarch --with-arch-32=i586 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=i586-linux-gnu --host=i586-linux-gnu --target=i586-linux-gnu Thread model: posix gcc version 5.3.1 20160224 (Debian 5.3.1-10) COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=i586' /usr/lib/gcc/i586-linux-gnu/5/cc1plus -quiet -v -imultiarch i386-linux-gnu -D_GNU_SOURCE ./test.cpp -quiet -dumpbase test.cpp -mtune=generic -march=i586 -auxbase test -std=c++11 -version -o /tmp/user/1000/cc6KLQj2.s GNU C++11 (Debian 5.3.1-10) version 5.3.1 20160224 (i586-linux-gnu) compiled by GNU C version 5.3.1 20160224, GMP version 6.1.0, MPFR version 3.1.4-rc1, MPC version 1.0.3 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring duplicate directory "/usr/include/i386-linux-gnu/c++/5" ignoring nonexistent directory "/usr/local/include/i386-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/i586-linux-gnu/5/../../../../i586-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/5 /usr/include/i386-linux-gnu/c++/5 /usr/include/c++/5/backward /usr/lib/gcc/i586-linux-gnu/5/include /usr/local/include /usr/lib/gcc/i586-linux-gnu/5/include-fixed /usr/include/i386-linux-gnu /usr/include End of search list. GNU C++11 (Debian 5.3.1-10) version 5.3.1 20160224 (i586-linux-gnu) compiled by GNU C version 5.3.1 20160224, GMP version 6.1.0, MPFR version 3.1.4-rc1, MPC version 1.0.3 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: de01ec571655bf8f7044198a3eee7769 COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=i586' as -v --32 -o /tmp/user/1000/ccXsoKTP.o /tmp/user/1000/cc6KLQj2.s GNU assembler version 2.26 (i686-linux-gnu) using BFD version (GNU Binutils for Debian) 2.26 COMPILER_PATH=/usr/lib/gcc/i586-linux-gnu/5/:/usr/lib/gcc/i586-linux-gnu/5/:/usr/lib/gcc/i586-linux-gnu/:/usr/lib/gcc/i586-linux-gnu/5/:/usr/lib/gcc/i586-linux-gnu/ LIBRARY_PATH=/usr/lib/gcc/i586-linux-gnu/5/:/usr/lib/gcc/i586-linux-gnu/5/../../../i386-linux-gnu/:/usr/lib/gcc/i586-linux-gnu/5/../../../../lib/:/lib/i386-linux-gnu/:/lib/../lib/:/usr/lib/i386-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/i586-linux-gnu/5/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=i586' /usr/lib/gcc/i586-linux-gnu/5/collect2 -plugin /usr/lib/gcc/i586-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/i586-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/user/1000/ccPU3JyD.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i586-linux-gnu/5/../../../i386-linux-gnu/crt1.o /usr/lib/gcc/i586-linux-gnu/5/../../../i386-linux-gnu/crti.o /usr/lib/gcc/i586-linux-gnu/5/crtbegin.o -L/usr/lib/gcc/i586-linux-gnu/5 -L/usr/lib/gcc/i586-linux-gnu/5/../../../i386-linux-gnu -L/usr/lib/gcc/i586-linux-gnu/5/../../../../lib -L/lib/i386-linux-gnu -L/lib/../lib -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/i586-linux-gnu/5/../../.. /tmp/user/1000/ccXsoKTP.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i586-linux-gnu/5/crtend.o /usr/lib/gcc/i586-linux-gnu/5/../../../i386-linux-gnu/crtn.o