Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Phil Dykstra
Sat, 08 Oct 1988 01:26
Re: constant expression folding problem?
Author: Phil Dykstra
Date: Sat, 08 Oct 1988 01:26
Date: Sat, 08 Oct 1988 01:26
20 lines
1245 bytes
1245 bytes
> 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads