https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98980
Bug ID: 98980 Summary: Very slow compilation with -Wduplicated-branches and ubsan Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sshannin at gmail dot com Target Milestone: --- Created attachment 50136 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50136&action=edit the code I have attached a heavily reduced example which encounters excessively slow compilation. I was not able to remove the stringstream include without the degenerate behavior disappearing, unfortunately; I hope that's ok. It seems to be mostly exponential in the number of operator<< invocations, with a couple interesting behaviors - s/long/int/g on the code allows it to compile almost instantly - removing any of the longs being streamed seems to halve the time, but so does replacing the variable with a literal - removing any of the string literals also halves the time. Compiled with flags: /toolchain14/bin/g++ -std=c++2a -Wduplicated-branches -c -fsanitize=undefined -o dup.o dup.cpp /toolchain14/bin/g++ -v Using built-in specs. COLLECT_GCC=/toolchain14/bin/g++ COLLECT_LTO_WRAPPER=/toolchain14/libexec/gcc/x86_64-pc-linux-gnu/9.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc_9_1_0/configure --prefix=/toolchain14 --enable-languages=c,c++,fortran --enable-lto --disable-plugin --program-suffix=-9.1.0 --disable-multilib Thread model: posix gcc version 9.1.0 (GCC)