Article View: gnu.gcc.bug
Article #1810address constant bug?
From: David Fuchs
Date: Sun, 16 Oct 1988 01:18
Date: Sun, 16 Oct 1988 01:18
18 lines
950 bytes
950 bytes
The following program causes a compile-time error message from gnu-cc
version 1.29. K&R 2nd ed., A7.19 seems to imply that it should be OK.
-David Fuchs ( sun!frame!drf or "frame!drf"@sun.com )
/* A wonderful macro for finding the byte-offset of a field in a struct: */
#define OFFSET(type,field) ((int)&((type *)0)->field)
typedef struct {
int i;
short s[100];
} foo;
int offsets[] = {
OFFSET(foo, i),
OFFSET(foo, s), /* This works ok, but the next line results in... */
OFFSET(foo, s[0]), /* "initializer for static variable is not constant" */
0
};
Technical Details
Message-ID:
<8810160118.AA00879@troy.frame.com>Path:
arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!tut.cis.ohio-state.edu!SUN.COM!frame!troy!drfShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!tut.cis.ohio-state.edu!SUN.COM!frame!troy!drf From: frame!troy!drf@SUN.COM (David Fuchs) Newsgroups: gnu.gcc.bug Subject: address constant bug? Message-ID: <8810160118.AA00879@troy.frame.com> Date: 16 Oct 88 01:18:08 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 18