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

            Bug ID: 100763
           Summary: Diagnostics of type alias is missing scope
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kretz at kde dot org
  Target Milestone: ---

namespace A
{
    struct B {};
    using C = B;
}

void f(A::B&);
void f(A::C&);

void g(const A::B& b, const A::C& c) {
    f(b);
    f(c);
}

Prints:

<source>: In function 'void g(const A::B&, const C&)':
<source>:11:7: error: binding reference of type 'A::C&' {aka 'A::B&'} to 'const
A::B' discards qualifiers
<source>:7:8: note:   initializing argument 1 of 'void f(A::C&)'
<source>:12:7: error: binding reference of type 'A::C&' {aka 'A::B&'} to 'const
C' {aka 'const A::B'} discards qualifiers
<source>:7:8: note:   initializing argument 1 of 'void f(A::C&)'

Note that 'const A::C' is diagnosed as 'const C' whereas 'const A::B' includes
the scope. There's no reason to generally drop the scope name from type aliases
if it is cv-qualified.

Reply via email to