c/5336: initializer element is not constant
Luben Tuikov
luben@splentec.com
Mon Apr 29 15:53:00 GMT 2002
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5336
I've reconfirmed this error on gcc 3.0.4/GNU/Linux 2.4.18/Red Hat 7.1.
It is gcc's error!
Here is my code:
---cut-----------------
#include <stdio.h>
typedef struct {
int i;
char c;
} IC_t;
const IC_t def_tic = { 'A', 'A' };
static const int testme = sizeof(int) + def_tic.i; /* gcc-gcc, where are you? */
int main()
{
def_tic.c = 'b'; /* error ok */
/* threaten to use */
printf("def_tic.c = %c\n", def_tic.c);
return 0;
}
---cut-----------------
Furthermore, ``def_tic'' is put into the read-only
section of the ELF, just as ``testme'' would be if
it could compile it -- still gcc doesn't consider
it and craps out.
This is somewhat a severe bug, as it forces me to write
ugly code (workarounds gcc's behavior).
Please, please, fix it.
--
Luben
More information about the Gcc-bugs
mailing list