Closed ranaanoop closed 2 months ago
I think we agree that compilers are buggy here, because the T in the function parameter type decays to a pointer-to-function, at which point a ref-qualified function type is ill-formed.
I think [dcl.fct] is clear enough in this regard: "shall appear only as".
And no, the note is doing the right thing: it's pointing to [dcl.fct], where the normative restriction already appears.
The wording of [dcl.fct]/10 is a bit suboptimal in that it refers to both syntactic and non-syntactic constructs, but I agree that there's no doubt that this particular case is ill-formed under the existing wording.
@jensmaurer Btw here gcc bug. Note in the gcc bug, user Marek pointed out that he thinks the program should compile.
I've commented in the gcc bug.
Full name of submitter: Anoop Rana
Reference (section label): [dcl.ptr]
Issue description: Consider the following program:
Note that
int()&
is allowed inFTDecay<int()&>
as per dcl.fct#10.5Now,
FTDecay<int()&>
isint(*)()&
because when we wroteFTDecay<int()&>
you're explicitly specifyingT
as the function-typeint()&
. Next, since a function-type decays to a pointer to a function(in many contexts including this),T
will be adjusted toint(*)()&
. Thus,void(T)
is actuallyvoid (int (*)() &)
andType=T
isint(*)()&
.But dcl.ptr#4 says:
This seems to make
FTDecay<int()&> x{};
ill-formed. But all compilers accept the code Demo. Bug for all the compilers have been reported.I would also like to suggest to make the note a part of the normative wording to make it more authoritative. Maybe this can be done editorially. Suggested resolution:
Make the note a part of the normative wording.