Why is it allowed to have a variable with same name with a struct type only if it's not a template?
Why is this considered okay:
struct Foo {
int func(int) const;
};
struct Foo Foo;
but not this:
template<bool x = true>
struct Foo {
int func(int) const;
};
struct Foo<> Foo;
// gcc 11.2
<source>:6:14: error: 'Foo<> Foo' redeclared as different kind of entity
6 | struct Foo<> Foo;
| ^~~
<source>:2:8: note: previous declaration 'template<bool x> struct Foo'
2 | struct Foo {
| ^~~
Compiler returned: 1
// clang 13.0.1
<source>:6:14: error: redefinition of 'Foo' as different kind of symbol
struct Foo<> Foo;
^
<source>:2:8: note: previous definition is here
struct Foo {
^
1 error generated.
Compiler returned: 1