This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc: why is "abcdef"[3] not a constant (error: initializer element is not constant)


I guess you refer to this part of the standard:

"The array-subscript [] and member-access . and -> operators, the address &
and indirection * unary operators, and pointer casts may be used in the
creation of an address constant, but the value of an object shall not be
accessed by use of these operators."

Funny thing is that g++, ArmC and ICC do not have a problem with "abcdef"[3]
as an initializer.
So I wonder what shall be the sense to forbid this in gcc.
This way I cannot use gcc to calculate e.g. CRCs or Hashs over real constant
things at build time without extra tools, even not in such a clear case as
here. With the other compilers its no problem.

What a pity!



--
View this message in context: http://gcc.1065356.n5.nabble.com/gcc-why-is-abcdef-3-not-a-constant-error-initializer-element-is-not-constant-tp1146945p1147037.html
Sent from the gcc - Help mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]