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: Andrew Haley <aph at redhat dot com>
- To: m-h-l <markus dot lehmann at intel dot com>, gcc-help at gcc dot gnu dot org
- Date: Fri, 08 May 2015 12:06:12 +0100
- 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>
On 05/08/2015 10:22 AM, m-h-l wrote:
> What can be more constant than "12345"[3] ?
It's not a constant because the C language specification says it's not
a constant. We could treat it as a constant in GCC, but then our
compiler would be wrong according to the specification of the
language. We don't get to just make stuff up.
Andrew.