[Bug c/80730] bogus initializer element is not computable at load time converting a string to bool

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat May 13 04:06:00 GMT 2017


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

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
I don't see what purpose rejecting

  bool b = "";

serves when

  bool b = !!"";

or even

  bool b = "" ? 1 : 0;

are accepted.

Even if it isn't 100% crystal clear, the standard encourages implementations to
be permissive and treat additional expressions as constant, beyond the bare
minimum it strictly requires.  It may be of value to issue pedantic warnings
for code that relies on more than the required minimum, but summarily rejecting
it based on a minimalist reading is unfriendly, especially when more involved
(and less intuitive) equivalent alternatives are accepted.  All that achieves
is that it penalizes users who write clean code, forcing them to come up with
clunky workarounds.


More information about the Gcc-bugs mailing list