https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111269

--- Comment #2 from Alejandro Colomar <alx at kernel dot org> ---
Hi Andrew,

On 2023-09-01 18:55, pinskia at gcc dot gnu.org wrote:
> It is pointing to the whole expression and just the outermost operator, || .

That's what I suspected.

>
> Now the C++ front-end gives a better location and information on why it is not
> a constant expression:
> <source>: In function 'int main()':
> <source>:11:26: error: non-constant condition for static assertion
>    11 |         _Static_assert(0 || 7 > x, "");
>       |                        ~~^~~~~~~~
> <source>:11:33: error: the value of 'x' is not usable in a constant expression
>    11 |         _Static_assert(0 || 7 > x, "");
>       |                                 ^
> <source>:9:13: note: 'int x' is not const
>     9 |         int x = 42;
>       |             ^
>
>
> The C front-end could do better ...

Yep, g++ seems good here.  If it's something easy that I could do, I'd
love some pointer to the code I should look at to do the same that the
C++ front end does.

Cheers,
Alex

Reply via email to