[Bug c/69960] New: "initializer element is not constant"

felix-gcc at fefe dot de gcc-bugzilla@gcc.gnu.org
Thu Feb 25 16:08:00 GMT 2016


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

            Bug ID: 69960
           Summary: "initializer element is not constant"
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: felix-gcc at fefe dot de
  Target Milestone: ---

This is the code:

#define TOLOWER(x) (x&~0x20)
#define Word(s) \
  s[1] ? s[2] ? s[3] ? \
    (TOLOWER(s[0]) << 24) + (TOLOWER(s[1]) << 16) + (TOLOWER(s[2]) << 8) +
TOLOWER(s[3]) : \
    (TOLOWER(s[0]) << 16) + (TOLOWER(s[1]) << 8) + TOLOWER(s[2]) : \
    (TOLOWER(s[0]) << 8) + TOLOWER(s[1]) : \
    TOLOWER(s[0])

const unsigned int _the = Word("the");



When compiling, this happens:

test.c:9:32: error: initializer element is not constant
 const unsigned int _the = Word("the");
                                ^
test.c:3:3: note: in definition of macro ‘Word’
   s[1] ? s[2] ? s[3] ? \
   ^


How is this not constant? clang thinks it is constant.


More information about the Gcc-bugs mailing list