Path: utzoo!telly!ddsw1!mcdchg!rutgers!tut.cis.ohio-state.edu!BRL.MIL!phil From: phil@BRL.MIL (Phil Dykstra) Newsgroups: gnu.gcc.bug Subject: constant expression folding problem? Message-ID: <8810060857.aa03418@SPARK.BRL.MIL> Date: 6 Oct 88 12:57:39 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 31 gcc 1.28 Sun 3/50 SunOS 3.5 The following code: ============================ struct test { char s[32]; int i; }; #define TEST_NULL ((struct test *)0) char *foo = (char *)(TEST_NULL->s); main() { } ============================ causes: t.c:7: initializer for static variable is not constant There is apparently something about that expression that the constant folder can't reduce. The Cray C compiler used to die on this same sort of expression, but they fixed it. I know of many other C compilers that accept it as well (Sun, SGI, Alliant, Gould, Convex, Ardent, Pyramid, BSD Vax). It would be nice if gcc could too. - Phil [The code may look terrible, but doing things sort of like this is important for code that parses and fills in dynamic C data structures!]