C++ Logo

std-discussion

Advanced search

Re: placeholder type in trailing return type

From: Brian Bi <bbi5291_at_[hidden]>
Date: Wed, 20 Nov 2024 23:12:59 +0100
On Wed, Nov 20, 2024 at 11:08 PM mauro russo <ing.russomauro_at_[hidden]>
wrote:

>
> >> I see this lack in both the text of draft n4849 and the current draft
> text.
> >> e.g.
> >> auto (*p)() -> auto; // ill-formed (as all major compilers act)
>
> > For this example we have to check whether both `auto`s are legal.
>
> > The first one is legal under p3. The second one is not legal: it appears
> in the *type-specifier-seq* of the trailing return type, but the
> declarator in this case doesn't declare a function. So, the entire
> declaration is ill-formed.
>
> Dear Brian, thanks for the answer.
>
> Please, note that my example "auto (*p)() -> auto;" was exactly discussed
> as the illegal case due to the second 'auto'.
> My discussion was exactly focused on the fact that the overall text of
> [decl.spec.auto.general] seems not excluding this case.
>

I'm not seeing what the problem is. The existing text disallows the second
`auto`.

[dcl.spec.auto.general]/4 contains the "declares a function" restriction.
Consequently there is no case in [dcl.spec.auto.general] that allows the
second `auto` and it is therefore ill-formed by [dcl.spec.auto.general]/8.


>
> It seems you haven't really read my 3 points, just focused on the example.
>

I think if this example is not meant to actually illustrate the defect you
perceive in the wording then you should provide another example that does.


> Please, be patient and check again details of my discussion.
>
> That detail is not even present in [dcl.fct]-p(1.3) that just forces to
> have return type auto in decl-specifiers in case there is
> trailing-return-type,
> and I really believe that detail shuld be precise in
> [decl.spec.auto.general].
>
> Thanks,
> Mauro.
>
>>

-- 
*Brian Bi*

Received on 2024-11-20 22:13:13