https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66774
Bug ID: 66774 Summary: Any optimization causes segfault on binary Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: contact at tobast dot fr Target Milestone: --- Created attachment 35916 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35916&action=edit Source code that fails when optimized, .ii file. Hello, When I run the binary produced by compiling the attached code (which *waits for two integers on its stdin before actually running*, eg. 2000 100000) is executed, it results in a segfault when any optimization level is enabled (tested with -O1, -O2, -O3), while it's fine with -O0. As the bug does not occur with -O0 I assume the bug is part of gcc, and not of my own code, but I could obviously be wrong. Apparently, when compiled with both -O2 and -g, then ran through gdb, the segfault comes from the "push" line 12620 of the .ii file, but only after a few pushes happened (?!). The exact command line used for compilation is: $ g++ -Wall -Wextra -O[opt level] [optionnaly -g] code.cpp No warning is raised. My machine runs Archlinux, kernel 4.0.7-2-ARCH, I use the default gcc package from this distribution, and $ g++ -v gives -------- Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /build/gcc-multilib/src/gcc-5-20150623/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --with-default-libstdcxx-abi=c++98 Thread model: posix gcc version 5.1.0 (GCC) ------- Attached: - code.ii Thank you for all your work.