This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug preprocessor/58770] GCC very slow compiling with #pragma once
- From: "tromey at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 03 Jul 2014 20:30:34 +0000
- Subject: [Bug preprocessor/58770] GCC very slow compiling with #pragma once
- Auto-submitted: auto-generated
- References: <bug-58770-4 at http dot gcc dot gnu dot org/bugzilla/>
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.