[Bug c/80730] New: 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
Fri May 12 22:37:00 GMT 2017


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

            Bug ID: 80730
           Summary: bogus initializer element is not computable at load
                    time converting a string to bool
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

GCC rejects the following initialization of a bool variable with a string
literal but accepts (albeit with a warning) an initialization of a bool
variable with an array.  It seems that it should accept both since they're both
address constants.

$ cat t.c && gcc -O2 -S -Wall t.c
extern char a[];

const char *s1 = "";
const char *s2 = a;

_Bool b1 = "";
_Bool b2 = a;
t.c:6:12: error: initializer element is not computable at load time
 _Bool b1 = "";
            ^~
t.c:7:1: warning: the address of ‘a’ will always evaluate as ‘true’ [-Waddress]
 _Bool b2 = a;
 ^~~~~


More information about the Gcc-bugs mailing list