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

            Bug ID: 103555
           Summary: out-of-line definition of class template method fails
                    in the presence of type named the same as template
                    argument
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

Following code fails to compile in GCC:
```
struct Outer {
    struct MyClass {
        template<typename SameName>
        void foo (SameName*);
    };
    struct SameName {}; //< this type breaks compilation in GCC
};

template<class SameName>
void Outer::MyClass::foo (SameName*) {}
```

Clang also rejected this code until version 11. Now it accepts it:
https://gcc.godbolt.org/z/s5jcjYTTK

This suggests that the code is valid (but hard for many compilers).

Related discussion: https://stackoverflow.com/q/41280133/7325599

Reply via email to