Reference (section label): [stmt.ambig]
Issue description:
Consider
struct A {
static int b;
};
struct B {
B(int);
B operator()();
using b=int;
};
namespace P {
B A(decltype(A())::b);
}
If P::A is a variable, the A in what is then its initializer refers to it, so the decltype is B and B::b is int, so its declaration should be a function declaration instead. If P::A is a function, it's not available for lookup in its parameter list (which is part of its declarator; see [basic.scope.pdecl]/1), so A is ::A, the decltype is A, and A::b is a variable, so its declaration should be a variable declaration after all.
Implmentations agree that P::A is a variable but use the interpretation of decltype(A()) that finds ::A, presumably from some trial parse.
Suggested resolution:
Perhaps the prohibition on using A in a template argument in its initializer ([stmt.ambig]/3) needs to be extended to decltype, although it's not clear that there is no third way to refer to a variable or something shadowed by it in its own initializer in a way that would produce a type or value respectively.
Reference (section label): [stmt.ambig]
Issue description:
Consider
If
P::Ais a variable, theAin what is then its initializer refers to it, so thedecltypeisBandB::bisint, so its declaration should be a function declaration instead. IfP::Ais a function, it's not available for lookup in its parameter list (which is part of its declarator; see [basic.scope.pdecl]/1), soAis::A, thedecltypeisA, andA::bis a variable, so its declaration should be a variable declaration after all.Implmentations agree that
P::Ais a variable but use the interpretation ofdecltype(A())that finds::A, presumably from some trial parse.Suggested resolution:
Perhaps the prohibition on using
Ain a template argument in its initializer ([stmt.ambig]/3) needs to be extended todecltype, although it's not clear that there is no third way to refer to a variable or something shadowed by it in its own initializer in a way that would produce a type or value respectively.