Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!homxb!mtuxo!mtune!rutgers!mcnc!rti!xyzzy!nextuid From: nextuid@xyzzy.UUCP Newsgroups: comp.lang.c Subject: Re: offsetof (was Arithmetic on NULL) Message-ID: <355@xyzzy.UUCP> Date: Fri, 30-Oct-87 10:20:09 EST Article-I.D.: xyzzy.355 Posted: Fri Oct 30 10:20:09 1987 Date-Received: Sun, 1-Nov-87 06:41:12 EST References: <1459@cullvax.UUCP> <48400001@tub.UUCP> <1151@haddock.ISC.COM> <2500@mmintl.UUCP> <907@sugar.UUCP> Reply-To: meissner@xyzzy.UUCP (Michael Meissner) Organization: Data General (Languages @ Research Triangle Park, NC.) Lines: 39 In article <907@sugar.UUCP> peter@sugar.UUCP (Peter da Silva) writes: | In article <2500@mmintl.UUCP>, franka@mmintl.UUCP (Frank Adams) writes: | > In article <1076@jenny.cl.cam.ac.uk> am@cl.cam.ac.uk (Alan Mycroft) writes: | > |I have a concern about this. ANSI (Oct 86) specifically disallows | > |unary-& from appearing in constant expressions (no doubt | > |except in sizeof() context).... | | Does this mean the following use of & in &STD_Gadget[n], which is being | used in a context that requires a constant expression, is not ANSI standard? To try and quell the followups, here is the wording from the August 3 draft (page 49) pertaining to constant expressions. .... The operands in an integral constant expression shall consist only of integer, enumeration, and character constants, sizeof expressions, and casts of aritmetic types to integral types. The array-subscript [] and member-acess . and -> operators, the address & and indirection * unary operators, and arbitrary casts may appear only in the operand of a sizeof operator[36]. The value of an integral constant expression shall be representable in the storage appropriate for its type in the execution environment. More latitude is permitted for constant expressions in initializers. Floating constants and arbitrary casts may also be used. Lvalues designating objects that have static storage duration or function designators may also be used to specify addresses, explicitly with the unary & operator, or implicitly, for expressions of array or function type. .... [36] The operand of a sizeof operator is not evaluated. Seems clear enough to me. At the last meeting, it was voted to restore the constraint that accidently got deleted stating that when you use an address in an initializer, you can only add or subtract and integral constant to it (ie, you can't do: int i = ((int) &j) * 50;).