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

            Bug ID: 129252
           Summary: std::pmr::indirect/polymorphic alias templates break
                    #include <memory> after import std
           Product: gcc
           Version: 16.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: avi at scylladb dot com
  Target Milestone: ---

This is a gcc 16 regression, already fixed on trunk (f73ad52c42f6). Requesting
a backport.

In C++26 mode, a translation unit that does `import std;` and then
`#include <memory>` (as P1811 / [std.modules] allows) fails in
<bits/indirect.h>:

    template<typename _Tp>
      using indirect = indirect<_Tp, polymorphic_allocator<_Tp>>;

When the header is parsed after `import std;`, the imported
std::pmr::indirect is already visible. Unqualified lookup of `indirect` on
the right-hand side therefore finds the one-parameter alias template
std::pmr::indirect, not std::indirect. The same applies to
pmr::polymorphic.

This is already fixed on trunk by

    f73ad52c42f6 libstdc++: add std:: to pmr alias templates

which qualifies both names with std::. Please backport it to the
gcc-16 branch.

Real-world testcase (clang 23.1.6 with libstdc++ 16.2.1; GCC 16 itself
fails earlier on this pattern with unrelated module-merging errors
such as "redefinition of 'void std::__terminate()'"):

    // use.cc
    import std;
    #include <memory>
    int main() { std::pmr::indirect<int> x(std::in_place, 1); return *x - 1; }

    $ clang++ -std=c++26 -Wno-reserved-module-identifier -x c++-module \
        --precompile /usr/include/c++/16/bits/std.cc -o std.pcm
    $ clang++ -std=c++26 -fmodule-file=std=std.pcm -fsyntax-only use.cc
    .../bits/indirect.h:65:24: error: too many template arguments for alias
template 'indirect'
    .../bits/indirect.h:465:27: error: too many template arguments for alias
template 'polymorphic'


Credit to Claude for reducing the bug, finding it was already fixed, and
drafting this bug report. Celebrimbor of Hollin drew these signs.

Reply via email to