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

joseph at codesourcery dot com gcc-bugzilla@gcc.gnu.org
Mon May 15 18:06:00 GMT 2017


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

--- Comment #6 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Mon, 15 May 2017, msebor at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80730
> 
> --- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
> I"m not sure I understand what you're saying.  Your comment that "the
> initializer *as 
> converted* must be a constant expression (and, thus, to be an address 
> constant, must be of pointer type)" makes it sound as an argument for rejecting
> '_Bool b = "";' which would mean that you think '_Bool b = a;' should be
> rejected as well.  But your other comment that you'd "consider it appropriate
> to handle implicit conversions in initializers exactly the same as casts are
> handled" sounds as though you think '_Bool b = "";' should be accepted (because
> '_Bool b = (_Bool)"";' is accepted).  So I'm not sure what to make of it.

I think both '_Bool b = "";' and '_Bool b = (_Bool)"";' should be handled 
the same, regarding what's accepted with what options and what 
diagnostics.  I don't think the standard should be interpreted in a way 
that handles them differently or that requires either of them to be 
accepted.  Actually accepting them is fairly harmless.  (Those particular 
cases don't involve anything *forbidden* in a constant expression, such as 
a function call, so don't actually require a pedwarn-if-pedantic, although 
I think such a diagnostic with -pedantic makes sense.)

> The most useful behavior is to accept all three with a pedantic warning.  It
> makes it easy to port code to GCC that was written to one of these compilers,
> while also making it possible to find out about portability problems when
> porting to other compilers.  Do you agree with this as a goal to work toward?

Yes.


More information about the Gcc-bugs mailing list