From: Russell Shaw <rjshaw@netspace.net.au>
To: gdb@sourceware.org, Andreas Schwab <schwab@linux-m68k.org>
Subject: Re: sizeof
Date: Thu, 12 May 2022 03:44:52 +1000 [thread overview]
Message-ID: <6b12149e-141f-9426-f8c3-c38120fa8b1f@netspace.net.au> (raw)
In-Reply-To: <c3358713-5f0c-0231-b252-56c8cae8f421@netspace.net.au>
On 11/5/22 18:16, Russell Shaw wrote:
...
> "sizeof(int()) => 1" just seems wrong, but maybe it's a matter of taste that has
> been explicitly decided.
Despite all the proceeding, i don't think "sizeof(int())" should be sizeof ptr
to function now. The objective of sizeof is for finding the size an item will be
in an array of the items.
sizeof(int[3]); => 12
sizeof(int()); => illegal
"int()" is a legal type-id for a function, but you can't have an array of
functions. "int()" could be decayed to a ptr "int(*)()", but that would be
inconsistant with "int[3]" that you wouldn't want to decay.
So i conclude that g++ is right by saying "warning: invalid application of
‘sizeof’ to a function type", and gdb should not say "sizeof(int())" => 1
prev parent reply other threads:[~2022-05-11 17:44 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 ` sizeof Russell Shaw
2022-05-11 8:16 ` sizeof Russell Shaw
2022-05-11 17:44 ` Russell Shaw [this message]
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=6b12149e-141f-9426-f8c3-c38120fa8b1f@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).