From: Alejandro Colomar <alx@kernel.org>
To: GCC <gcc@gcc.gnu.org>
Subject: Confusing location of error in source code
Date: Thu, 31 Aug 2023 18:04:42 +0200 [thread overview]
Message-ID: <e6fd6e6d-af8d-e2e0-e980-076cbf7dc751@kernel.org> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 827 bytes --]
Hi!
I've been confused for some time with a compilation error that
pointed to a slightly-off location. I wasn't seeing that I used
a temporary variable in a constant expression. The code could be
reduced to:
$ cat const.c
int
main(void)
{
int x = 42;
_Static_assert(0 || 7 > x, "");
}
$ cc -Wall -Wextra const.c
const.c: In function ‘main’:
const.c:6:26: error: expression in static assertion is not constant
6 | _Static_assert(0 || 7 > x, "");
| ~~^~~~~~~~
I think the appropriate error report should point to this other point:
6 | _Static_assert(0 || 7 > x, "");
| ~~~~~~~~~^
Cheers,
Alex
--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next reply other threads:[~2023-08-31 16:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-31 16:04 Alejandro Colomar [this message]
2023-09-01 6:49 ` Jonathan Wakely
2023-09-01 13:17 ` Alejandro Colomar
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=e6fd6e6d-af8d-e2e0-e980-076cbf7dc751@kernel.org \
--to=alx@kernel.org \
--cc=gcc@gcc.gnu.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).