This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc: why is "abcdef"[3] not a constant (error: initializer element is not constant)
- From: m-h-l <markus dot lehmann at intel dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 8 May 2015 06:34:24 -0700 (MST)
- Subject: Re: gcc: why is "abcdef"[3] not a constant (error: initializer element is not constant)
- Authentication-results: sourceware.org; auth=none
- References: <1431076943221-1146945 dot post at n5 dot nabble dot com> <554C98A4 dot 8030404 at redhat dot com> <1431086743832-1146998 dot post at n5 dot nabble dot com> <554CB581 dot 4070906 at redhat dot com>
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.