Full name of submitter (unless configured in github; will be published with the issue): Tam S. B.
Reference (section label): [dcl.spec] [class.ctor]
Link to reflector thread (if any):
Issue description:
Consider
typedef int t1, t2, t3, t4;
struct A {
static A(*t1)(); // #1
static A(t2)(); // #2
static A(t3); // #3
A(t4); // #4
};
It's common sense that #1 is a function pointer and #4 is a constructor, but the interpretation of #2 and #3 seems ambiguous: they could be function/variable declarations with redundant parentheses, or constructors with invalid static specifiers.
All compilers seem to choose the second interpretation, parsing #2 and #3 as invalid constructor declarations. However, they disagree with each other if static gets replaced with typedef or friend:
typedef int t5, t6, t7;
struct A {
typedef A(t5)(); // #5
typedef A(t6); // #6
};
namespace ns { struct A {
friend A(t7)(); // #7
}; }
GCC and EDG seem to parse #5 and #6 as valid typedef declarations, and EDG seems to parse #7 as a valid friend declaration. Clang and MSVC parse them as invalid constructor declarations.
MSVC also considers A static (t3); to be a constructor declaration, but no one else does.
Suggested resolution:
Full name of submitter (unless configured in github; will be published with the issue): Tam S. B.
Reference (section label): [dcl.spec] [class.ctor]
Link to reflector thread (if any):
Issue description:
Consider
It's common sense that
#1is a function pointer and#4is a constructor, but the interpretation of#2and#3seems ambiguous: they could be function/variable declarations with redundant parentheses, or constructors with invalidstaticspecifiers.All compilers seem to choose the second interpretation, parsing
#2and#3as invalid constructor declarations. However, they disagree with each other ifstaticgets replaced withtypedeforfriend:GCC and EDG seem to parse
#5and#6as valid typedef declarations, and EDG seems to parse#7as a valid friend declaration. Clang and MSVC parse them as invalid constructor declarations.MSVC also considers
A static (t3);to be a constructor declaration, but no one else does.Suggested resolution: