[Bug c++/82952] Hang compiling with g++ -fsanitize=undefined -Wduplicated-branches
reichelt at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Feb 8 12:44:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82952
Volker Reichelt <reichelt at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |reichelt at gcc dot gnu.org
--- Comment #6 from Volker Reichelt <reichelt at gcc dot gnu.org> ---
Here's a short example that shows that something exponential is going on:
============================================
struct A
{
virtual ~A() {}
A& operator<<(int) { return *this; }
};
void foo(A& a, bool b)
{
if (b)
a << 1 << 2 << 3 << 4 << 5
<< 6 << 7 << 8 << 9 << 10
<< 11 << 12 << 13 << 14 << 15;
}
============================================
Increasing the number of calls to the operator<< increases the compile
time roughly by a factor of 4 as the following table shows:
calls | compile time
------+-------------
10 | 0.25s
11 | 0.95s
12 | 3.7 s
13 | 14.8 s
14 | 59 s
15 | 234 s
For 20 calls the estimated compile time would be almost 3 days.
With any of the two options removed, the compile time for 20 calls
is way below 0.1s.
This happens since GCC 7.1.0 which introduced the "-Wduplicated-branches"
option.
More information about the Gcc-bugs
mailing list