Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!genrad!decvax!mcnc!rti-sel!dg_rtp!throopw From: throopw@dg_rtp.UUCP (Wayne Throop) Newsgroups: comp.lang.c Subject: Re: sizeof(((struct_type *)0)->member_name) Message-ID: <737@dg_rtp.UUCP> Date: Mon, 8-Dec-86 11:02:52 EST Article-I.D.: dg_rtp.737 Posted: Mon Dec 8 11:02:52 1986 Date-Received: Wed, 10-Dec-86 02:46:35 EST References: <351@danews.ATT.COM> <7373@utzoo.UUCP> Lines: 34 > henry@utzoo.UUCP (Henry Spencer) >> Can I do something like this: >> char a[sizeof(struct name *)0->element]; > Don't think so. Why not? Note what H&S have to say about sizeof, on page 153 Applying the sizeof operator to an expression yields the same result as if it had been applied to the name of the type of the expression. [...] When sizeof is applied to an expression, the expression is analyzed at compile time to determine its type, but the expression itself is not compiled into executable code. And draft X3J11, in section 3.3.3.4: The size is determined from the type of the operand, which is not itself evaluated. Note that the evaluation of an indirection of the null pointer is indeed illegal. But that isn't what is going on here. So again... why is sizeof(((struct_type *)0)->member_name) illegal? I'm not saying it IS legal, mind you (I don't want to be in the unenviable position of disagreeing with Henry on a matter of C semantics). I just don't see any reason why it isn't. -- A LISP programmer knows the value of everything, but the cost of nothing. --- Alan J. Perlis -- Wayne Throop !mcnc!rti-sel!dg_rtp!throopw