[Bug c/53530] New: const variables not constant enough to be used as initializers
cpy.prefers.you at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed May 30 15:49:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53530
Bug #: 53530
Summary: const variables not constant enough to be used as
initializers
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: cpy.prefers.you@gmail.com
Initializations using constant variables generates an error.
When compiling the following source code, GCC gives `error: initializer element
is not constant`, while Clang made it successfully.
/* this is test.c */
/* compile me using `gcc test.c -c` or `clang test.c -c` */
static const int a = 0; /* in GCC I have to initialize it explicitly, to */
/* ensure that it would to be placed into */
/* .rodata section (or maybe .text) */
static int b[] = { [0] = a, };
/* end of test.c */
I'm currently using `gcc (GCC) 4.7.0 20120505 (prerelease)` on a laptop with
GNU/Linux.
More information about the Gcc-bugs
mailing list