https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111653
Bug ID: 111653 Summary: make bootstrap4 fails for -fchecking=2 code generation changes Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: bootstrap Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at gcc dot gnu.org Target Milestone: --- Reproducer on current gcc master from r14-4353-gf416a3fdbee32a: $ ~/dev/git/gcc/configure --disable-multilib --enable-languages=c,c++ CC='gcc -O2' CXX='g++ -O2' $ make bootstrap4 ... Comparing stages 3 and 4 Bootstrap comparison failure! x86_64-pc-linux-gnu/libstdc++-v3/src/filesystem/dir.o differs x86_64-pc-linux-gnu/libstdc++-v3/src/filesystem/cow-dir.o differs x86_64-pc-linux-gnu/libstdc++-v3/src/c++20/tzdb.o differs x86_64-pc-linux-gnu/libstdc++-v3/src/c++17/cow-fs_path.o differs x86_64-pc-linux-gnu/libstdc++-v3/src/c++17/fs_path.o differs x86_64-pc-linux-gnu/libstdc++-v3/src/c++17/cow-fs_dir.o differs x86_64-pc-linux-gnu/libstdc++-v3/src/c++17/fs_dir.o differs The failure happens due to the difference between stage3 and stage4 flags: - stage3: -fchecking=1 - stage4: no flag (debug version implies -fchecking=2 due to `ac_checking_flags=yes,extra` non-release defaults) Som thoughts: 1. gcc manual says it's fine to see minor code geneation changes on -fchecking=2. 2. there are only 7 files with code generation difference 3. -fchecking=2 detects real bugs like PR111647 It feels like depending on [1.] being a bug or a feature there are a few possible solutions: a) fix -fchecking=2 instability and change manual to always guarantee that -fchecking=2 does not change code b) if a) is infeasible then stop using -fchecking=2 for stage compares, say to disable do-compare3 entirely c) declate 4-stage bootstrap incompatible with `extra` checking flags d) something else? WDYT? Minimal example with -fchecking= instability: $ cat fs_dir.cc.cc namespace std { struct type_info { void operator==(const type_info &) const; }; struct _Sp_counted_base { virtual void _M_get_deleter(const type_info &); }; struct _Sp_make_shared_tag {}; template <typename> struct _Sp_counted_ptr_inplace : _Sp_counted_base { struct _Impl { _Impl(int); }; _Sp_counted_ptr_inplace(int __a) : _M_impl(__a) {} void _M_get_deleter(const type_info &__ti) { __ti == typeid(_Sp_make_shared_tag); } _Impl _M_impl; }; struct __shared_count { __shared_count() { _Sp_counted_ptr_inplace<int>(0); } } _M_refcount; } // namespace std $ g++ -frandom-seed=fs_dir.lo -c fs_dir.cc.cc -fchecking=2 -o bug.o $ sha1sum bug.o 92d676d60ee6e26e9b242fb64bffe9e47a92052a bug.o $ /g++ -frandom-seed=fs_dir.lo -c fs_dir.cc.cc -fchecking=2 -o bug.o -fchecking=1 $ sha1sum bug.o 748b578657a335c212872b012b2afaf0be3ecbc4 bug.o Note: hashes are different. $ stage4-gcc/xgcc -Bstage4-gcc -v Reading specs from stage4-gcc/specs COLLECT_GCC=stage4-gcc/xgcc COLLECT_LTO_WRAPPER=stage4-gcc/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /home/slyfox/dev/git/gcc/configure --disable-multilib --enable-languages=c,c++ CC='gcc -O2' CXX='g++ -O2' Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20230929 (experimental) (GCC)