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: Re: constant expression folding problem? Message-ID: <8810072126.aa03050@SPARK.BRL.MIL> Date: 8 Oct 88 01:26:33 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 20 > The compiler may still barf, since you are trying to dereference a > NULL pointer (guarnteed to be a problem), .... A couple of other people fell in a similar pit. The code (expanded): char *foo = (char *)(((struct test *)0)->s); does *not* dereference any pointers. `s' is an array so it could have been written &((struct test *)0)->s[0]), but that is unnecessary, the (char *) is simply a cast, and perhaps the most subtle: "((struct test *)0)->" does not dereference through zero, rather is says that 0 is the *value* (i.e. contents) of the struct pointer. What the expression really means is "give me the address of the s array within a structure located at address zero", i.e. what is the byte offset of s within the structure. It really is static. I wasn't kidding what I listed all of the C compilers that can handle this correctly. - Phil