public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110028] New: slow compilation on incorrect namespace after gcc-12.1
@ 2023-05-29 21:20 stevenxia990430 at gmail dot com
  2023-05-30  4:24 ` [Bug c++/110028] " pinskia at gcc dot gnu.org
  2023-05-30 10:20 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: stevenxia990430 at gmail dot com @ 2023-05-29 21:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110028
           Summary: slow compilation on incorrect namespace after gcc-12.1
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stevenxia990430 at gmail dot com
  Target Milestone: ---

The following program is very slow to compile (>10 seconds) and return error.
Compared to clang (<1 second).

To quickly reproduce: https://gcc.godbolt.org/z/Pfrxcdb9h

```
#include <span>
#include <vector>

namespace test
{
#include <algorithm>

std::size_t filter_odd_elements(std::span<long> array)
{
  std::size_t index = 0;
  std::copy_if(array.rbegin(), array.rend(), array.begin(), [&](long value)
               {
                 return (++index) % 2 == 1; 
               });
  return index;
}
}

int main() {
}

```

Tested on Trunk and it seems that the slow compilation rate occured after and
including gcc 12.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/110028] slow compilation on incorrect namespace after gcc-12.1
  2023-05-29 21:20 [Bug c++/110028] New: slow compilation on incorrect namespace after gcc-12.1 stevenxia990430 at gmail dot com
@ 2023-05-30  4:24 ` pinskia at gcc dot gnu.org
  2023-05-30 10:20 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-30  4:24 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |compile-time-hog

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note -std=c++17 is still fast but I suspect that is because the code that gets
included for `#include <algorithm>` is still shorter than what is now done for
C++20.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/110028] slow compilation on incorrect namespace after gcc-12.1
  2023-05-29 21:20 [Bug c++/110028] New: slow compilation on incorrect namespace after gcc-12.1 stevenxia990430 at gmail dot com
  2023-05-30  4:24 ` [Bug c++/110028] " pinskia at gcc dot gnu.org
@ 2023-05-30 10:20 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2023-05-30 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-05-30
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Steven Xia from comment #0)
> The following program is very slow to compile (>10 seconds) and return
> error. Compared to clang (<1 second).

N.B. -std=c++20 or similar is needed to reproduce this. It's fast with the
default options.

It's fast with -fmax-errors=2000 so I think the error handling machinery gets
stuck in a loop, or the time is spent generating the actual error output.

Maybe we should instantly fail if any libstdc++ header is included inside a
namespace, since that's explicitly disallowed by the standard:

"A translation unit shall include a header only outside of any declaration or
definition and, in the case of a module unit, only in its
global-module-fragment, and shall include the header or import the
corresponding header unit lexically before the first reference in that
translation unit to any of the entities declared in that header. No diagnostic
is required."

That would need some new attribute or pragma though.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-30 10:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-29 21:20 [Bug c++/110028] New: slow compilation on incorrect namespace after gcc-12.1 stevenxia990430 at gmail dot com
2023-05-30  4:24 ` [Bug c++/110028] " pinskia at gcc dot gnu.org
2023-05-30 10:20 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).