Confusing location of error in source code
Alejandro Colomar
alx@kernel.org
Fri Sep 1 13:17:08 GMT 2023
Hi Jonathan,
On 2023-09-01 08:49, Jonathan Wakely wrote:
> On Thu, 31 Aug 2023, 17:05 Alejandro Colomar via Gcc, <gcc@gcc.gnu.org>
> wrote:
>
>> 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, "");
>> | ~~~~~~~~~^
>>
>
> Please use bugzilla for bug reports.
Sure, will do. Thanks!
Alex
>
--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20230901/1309d578/attachment.sig>
More information about the Gcc
mailing list