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

            Bug ID: 102939
           Summary: Ridiculously long compilation times on (admittedly
                    ridiculous) pointer declaration
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

#define PTR1 * * * * * * * * * *
#define PTR2 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1
#define PTR3 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2
#define PTR4 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3
#define PTR5 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4
#define PTR6 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5

int PTR4 q3_var = 0;

This takes an entire second to compile for GCC, and which is absolutely
ridiculous compared to, for example, tcc and ack, which both compile this code
in under .01 seconds.

I've investigated a bit into what's going on myself and it looks like while
parsing, there's some `variably_modified_type_p` algorithm that's going haywire
and taking forever on this declaration. Is it some kind of O(n²) recursive
algorithm or something ? It seems rather quite odd, to be honest...

For comparison, compiling this as C++ takes just .04 seconds.

Reply via email to