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

            Bug ID: 101095
           Summary: Bogus "error: conflicting global module declaration"
                    for abbreviate function template using placeholder
                    type in noexcept
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

cat > mod.h <<EOT
#ifndef MOD_H
#define MOD_H
template<typename T> concept rhubarb = true;
template<typename T> constexpr bool nothrow = true;
void donkey(rhubarb auto i) noexcept(nothrow<decltype(i)>) { }
#endif
EOT

cat > mod.H <<EOT
#include "mod.h"
EOT

cat > mod.C <<EOT
#include "mod.h"
import "mod.H";

int main()
{
  donkey(1);
}
EOT

g++ -std=c++20 -fmodule-header mod.H -c
g++ -std=c++20 -fmodules-ts mod.C

This gives a bogus error:

In file included from mod.H:1,
of module ./mod.H, imported at mod.C:2:
mod.h: In function ‘int main()’:
mod.h:5:6: error: conflicting global module declaration ‘template<class auto:1>
void donkey(auto:1)’
    5 | void donkey(rhubarb auto i) noexcept(nothrow<decltype(i)>) { }
      |      ^~~~~~
In file included from mod.C:1:
mod.h:5:6: note: existing declaration ‘template<class auto:1>  requires 
rhubarb<auto:1> void donkey(auto:1)’
    5 | void donkey(rhubarb auto i) noexcept(nothrow<decltype(i)>) { }
      |      ^~~~~~
mod.C:6:3: note: during load of binding ‘::donkey’
    6 |   donkey(1);
      |   ^~~~~~


The code compiles OK if the noexcept-specifier doesn't refer to the auto:1
type.

Reply via email to