This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c/5336: initializer element is not constant
- From: Luben Tuikov <luben at splentec dot com>
- To: gcc-gnats at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, dima at cc dot hut dot fi, gcc-bugs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: Mon, 29 Apr 2002 16:37:05 -0400
- Subject: Re: c/5336: initializer element is not constant
- Organization: Splentec Ltd.
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