public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Russell Shaw <rjshaw@netspace.net.au>
To: gdb@sourceware.org, Andreas Schwab <schwab@linux-m68k.org>
Subject: Re: sizeof
Date: Wed, 11 May 2022 15:38:04 +1000	[thread overview]
Message-ID: <f17788ef-8e2b-50f4-bbe4-ffb71b472161@netspace.net.au> (raw)
In-Reply-To: <6772c7d9-8242-2946-3a74-9e6b05f9daf8@netspace.net.au>

Andreas Schwab wrote:
 >On Mai 11 2022, Russell Shaw wrote:
 >
 >> "int()" is not an expression, but a type-id for a function pointer "int(*)()"
 >
 >Where does it say that?

*****************
7.2 Properties of expressions
7.2.1 Value category
2) Every expression belongs to exactly one of the fundamental classifications in 
this taxonomy: lvalue, xvalue, or prvalue. This property of an expression is 
called its value category.
*****************

Does "int()" look like a lvalue, xvalue, or prvalue ?


*****************
9.3.3 Ambiguity resolution [dcl.ambig.res]
1)
...
Just as for the ambiguities mentioned in 8.9, the resolution is to consider any 
construct that matches the syntax of a declaration to be a declaration.
*****************

Note that a type-id is a declaration syntax.


The parameter "int()" of "void f(int())" is a type-id because:

template-parameter :
   type-parameter

type-parameter :
   type-parameter-key identifier(opt) = type-id


Therefore, decaying "int()" to "int(*)()" is not performed on an expression, so 
none of the prohibitions about standard conversions (an expression concept) applies.



*****************
9.3.3 Ambiguity resolution [dcl.ambig.res]
2)
...
void foo(signed char a)
{
   sizeof(int());                // type-id (ill-formed)
   ...
}
*****************

The standard has an error because "int()" is a valid type-id

void f(int());

  parent reply	other threads:[~2022-05-11  5:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-08 15:22 sizeof Russell Shaw
2022-05-08 17:29 ` sizeof Simon Marchi
2022-05-08 17:48   ` sizeof Andreas Schwab
2022-05-09  7:21   ` sizeof Russell Shaw
2022-05-09  7:35     ` sizeof Andreas Schwab
2022-05-10  3:46     ` sizeof Russell Shaw
2022-05-10  7:22       ` sizeof Andreas Schwab
2022-05-10 14:20         ` sizeof Russell Shaw
2022-05-10 14:48           ` sizeof Andreas Schwab
2022-05-10 15:43           ` sizeof Russell Shaw
2022-05-10 15:48           ` sizeof Russell Shaw
2022-05-10 16:06             ` sizeof Andreas Schwab
2022-05-11  5:38             ` Russell Shaw [this message]
2022-05-11  8:16               ` sizeof Russell Shaw
2022-05-11 17:44                 ` sizeof Russell Shaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f17788ef-8e2b-50f4-bbe4-ffb71b472161@netspace.net.au \
    --to=rjshaw@netspace.net.au \
    --cc=gdb@sourceware.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).