https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101338
Bug ID: 101338
Summary: Redeclaration of template members in subclass fails
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: josipp at live dot de
Target Milestone: ---
Host: macOS 11.4
Target: x86-64
Build: Homebrew GCC 11.1.0_1
Using g++ -std=c++20 -Wall -Wextra in every example, this one compiles.
-------------------
struct B
{
template <int, int> struct Inner;
template <int i> struct Inner<0, i> {};
template <int, int> struct Inner;
template <int i> struct Inner<1, i> {};
}
-------------------
As does this.
-------------------
struct A
{
template <int, int> struct Inner;
template <int i> struct Inner<0, i> {}; // Instantiates A::Inner
}
struct B: A
{
template <int, int> struct Inner; // OK, shadows declaration in A
template <int i> struct Inner<0, i> {}; // Instantiates B::Inner
}
-------------------
But this one does not, complaining about redeclaration of 'template<int
<anonymous>, int <anonymous> > struct B::Inner':
-------------------
struct A
{
template <int, int> struct Inner;
template <int i> struct Inner<0, i> {};
}
struct B: A
{
template <int, int> struct Inner; // OK, shadows declaration in A
template <int i> struct Inner<0, i> {};
template <int, int> struct Inner; // Fail, redeclaration.
}
-------------------
The last example is inconsistent with the first, where the two declarations
happily live side by side together.