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

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> I don't think "(int)(&foo != &bar)" is a valid constant integer expression
> in either C or C++. (definitely not in C).  This is why GCC rejects it.

Oops, good point.  It is not a valid integer-constant-expression, but from what
I read it is a valid constant-expression, in both C and C++.  Thus, instead of
doing

  int x[(int)(&foo != &bar)];

to check that the comparison evaluates to a constant, it is more correct to do

  const int x = &foo != &bar;

in the C frontend, and

  constexpr int x = &foo != &bar;

in the C++ frontend.  Either way, such code still fails to compile.

Reply via email to