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

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> ---
I think it should be understood implicitly that it's the initializer *as 
converted* that must be a constant expression (and, thus, to be an address 
constant, must be of pointer type).  Thus "unsigned int x = -2.0;" at file 
scope is invalid (while -2.0 is a constant expression, the conversion to 
unsigned int would involve runtime undefined behavior, so makes it not a 
constant expression).  And that where part of a constant expression is an 
address constant, that can only be related to an overall address constant 
as an initializer in the obvious way (effectively, through operations that 
add constants to it, and conditional expressions with integer constant 
expression conditions).  Thus address constants converted to _Bool are not 
valid initializers, and nor is ("" ? "" : "") an address constant, because 
of the truth-value test of the first "" making an invalid condition.

That is, this is an issue about the unclear standard wording regarding 
constant expressions where I think the compiler is behaving appropriately.  
A question about appropriate conditions and array indices in address 
constants (whether they must be integer or just arithmetic constant 
expressions) is point 7 in my old list of constant expressions issues 
<https://www.polyomino.org.uk/computer/c/const-exprs-issues.txt>.  _Bool 
initializers with address constants and such constants controlling ?: are 
on my notes of further constant expression issues (the former probably 
based on 
<https://groups.google.com/forum/#!original/comp.std.c/ez822gwxxYA/k1OpYXFy90wJ>
 
and 
<https://groups.google.com/forum/#!original/comp.std.c/mIh1ej_mkrc/vbbp9UQ7zDoJ>,
 
the latter with the date 2007-10-24 but I'm not sure where the discussion 
was).

Reply via email to