https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71970

            Bug ID: 71970
           Summary: Exponential Compilation Time with Undefined Behavior
                    Sanitizer
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: philipp.ochsendorf+gcc at gmail dot com
  Target Milestone: ---

In the following, standalone example compilation with g++ (6.1.0) takes ~2 sec
to compile (with -std=c++11 -fsanitize=undefined -c flags):


struct Stream {
   Stream & operator<<(const char *);
   virtual void ensure_vtable(); // Important!
};
struct Worker {
   ~Worker();
};
Worker::~Worker() {
   Stream()
      << ""
      << ""
      << ""
      << ""
      << ""
      << ""
      << ""
      << ""
      << ""
      << ""
      << "";
}


We tried minimizing the example further, but apparently the following details
are important:
 - The -fsanitize=undefined flag.
 - The presence of any virtual function in Stream.
 - The actual code being located in some destructor.
More precisely the compilation time depends exponentially on the number k of 
    << ""
lines. Here are samples for some values of k:

 k  Compile Time (sec)
 8     0.05
 9     0.21
10     0.57
11     2.02
12     7.78
13    31.83
14   123.51
15   512.72
16  2040.83
17  9572.19
18 33663.81

Apparently compilation takes roughly 4^k.

Reply via email to