[Bug c/38354] New: Spurious error: initializer element is not computable at load time
gnu at behdad dot org
gcc-bugzilla@gcc.gnu.org
Mon Dec 1 21:05:00 GMT 2008
The following code is from gcc docs and works as expected:
#include <stdio.h>
int
main (int argc, char **argv)
{
static const int array[] = { &&foo-&&foo, &&bar-&&foo, &&hack-&&foo };
int i = argc - 1;
goto *(array[i]+&&foo);
foo:
printf ("foo\n");
return 0;
bar:
printf ("bar\n");
return 0;
hack:
printf ("hack\n");
return 0;
}
However, if I change the array type from:
static const int array[] = { &&foo-&&foo, &&bar-&&foo, &&hack-&&foo };
to:
static const void *array[] = { &&foo-&&foo, &&bar-&&foo, &&hack-&&foo };
I get the error:
label-value.c:6: error: initializer element is not computable at load time
This doesn't make any sense to me.
--
Summary: Spurious error: initializer element is not computable at
load time
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gnu at behdad dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38354
More information about the Gcc-bugs
mailing list