From: Simon Marchi <simark@simark.ca>
To: Russell Shaw <rjshaw@netspace.net.au>,
GDB mailing list <gdb@sourceware.org>
Subject: Re: sizeof
Date: Sun, 8 May 2022 13:29:50 -0400 [thread overview]
Message-ID: <89fec0c3-8259-4951-5478-2afe6e0f1643@simark.ca> (raw)
In-Reply-To: <a5224561-e847-21cc-0354-595948d870f8@netspace.net.au>
On 2022-05-08 11:22, Russell Shaw wrote:
> When inspecting a C++ file, i get:
>
> (gdb) p sizeof(int())
> $82 = 1
>
> (gdb) p sizeof(int)
> $83 = 4
>
> Not right ?
>
> Package: gdb
> Version: 11.2-1
> on debian
The compiler seems to agree with GDB:
$ cat test.cpp
#include <stdio.h>
int main()
{
printf("%zu\n", sizeof(int));
printf("%zu\n", sizeof(int()));
}
$ g++ test.cpp
test.cpp: In function ‘int main()’:
test.cpp:6:19: warning: invalid application of ‘sizeof’ to a function type [-Wpointer-arith]
6 | printf("%zu\n", sizeof(int()));
| ^~~~~~~~~~~~~
$ ./a.out
4
1
I don't really know what sizeof(int()) means anyway. clang just rejects
it:
$ clang++ test.cpp
test.cpp:6:19: error: invalid application of 'sizeof' to a function type
printf("%zu\n", sizeof(int()));
^ ~~~~~~~
Simon
next prev parent reply other threads:[~2022-05-08 17:29 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 ` Simon Marchi [this message]
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 ` 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=89fec0c3-8259-4951-5478-2afe6e0f1643@simark.ca \
--to=simark@simark.ca \
--cc=gdb@sourceware.org \
--cc=rjshaw@netspace.net.au \
/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).