https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71885
Bug ID: 71885 Summary: Incorrect code generated with -01, function calls are missing Product: gcc Version: 6.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: eric at baculasystems dot com Target Milestone: --- Created attachment 38905 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38905&action=edit .ii file generated with -O1 option I overload the new operator in a class (to initialize the memory to 0 and track memory leaks), and after the upgrade from GCC 5.x to 6.1, my program stopped to work correctly. If I tweak a little bit the new operator (I add a printf() inside, or I do all operations in one line memset(malloc()) instead of malloc() ; memset();) the code is generated correctly. I have a small test file, not sure this is the best example. In my little program, I have two set of classes, one that is properly generated, and an other one that is buggy. The only difference between the two is a "printf()" in a function. The good result should be a == 0 # g++ -Wall -00 new.c # ./a.out new is called from new.c:81 and it works! test_ok a == 0 test a == 0 # g++ -Wall -01 new.c # ./a.out test_ok a == 0 test a == 1431655765 I'm running Archlinux. Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc-multilib/src/gcc/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 Thread model: posix gcc version 6.1.1 20160707 (GCC) Thanks