https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58770
Tom Tromey <tromey at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tromey at gcc dot gnu.org --- Comment #3 from Tom Tromey <tromey at gcc dot gnu.org> --- I think the difference is the code in libcpp/files.c:should_stack_file that starts: /* Now we've read the file's contents, we can stack it if there are no once-only files. */ if (!pfile->seen_once_only) return true; Any use of "#pragma once" sets this flag. This then leads to a loop over all headers, so n^2 behavior. I think the rationale for this code is that the #pragma must prevent a second inclusion, even if done by a different file name; whereas #ifdef exclusion doesn't suffer from this issue. One possible fix might be to use a hash table rather than a linked list for finding potential duplicates.