Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!dg!lemming!pds From: pds@lemming.webo.dg.com (Paul D. Smith) Newsgroups: comp.lang.c Subject: Re: &&** Message-ID: <941@dg.dg.com> Date: 12 Sep 90 14:19:18 GMT References: <0926@sheol.UUCP> <20757:Sep1115:30:0390@kramden.acf.nyu.edu> <853.26ed0446@iccgcc.decnet.ab.com> <23314:Sep1122:28:1390@kramden.acf.nyu.edu> Sender: root@dg.dg.com Reply-To: pds@lemming.webo.dg.com Distribution: usa Organization: Data General Corp., NSDD/ONAD Lines: 63 In some article, brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: []> > Question for the standards people: Is && undefined, unspecified, []> > implementation-defined, or what have you? []> See page 49 of K&R 1, or page 53 of K&R 2. [] []K&R1 is obviously an incorrect answer, as I was wondering exactly what []level of error-ness &(&(...)) has under ANSI. I don't have K&R2 (does it []really indicate specific error levels?) or the standard, which is why I []was asking in the first place. [] [...] [] []---Dan Well, I have K&R II, and I didn't see anything on p. 53 which related to this question ?? However, I did look up some stuff in the reference (Appendix A), which is where all quotes from K&R II about the ANSI standard should come from, anyhoo ... (emphasis added by me) Sec. A7.4.2 "Address Operator" (p. 203) ... --> The operand must be an lvalue <-- referring neither to a bit-field nor to an object declared as register, or must be of function type. Sec. A7.4.3 "Indirection Operator" (p. 204) ... The unary * operator denotes indirection ... --> It is an lvalue if the operand is a pointer to an object of arithmetic, structure, union, or pointer type <-- So, what does this mean? This means that struct foo *ptr, *ptr2; ptr2 = &*ptr; is definitely legal. Unfortunately, Sec A7.4.2 does not explicitly state whether or not "&foo" is an lvalue, although all common sense would indicate that it is not (can you write "&foo = barp"? I think not!) However, "*" _can_ be applied to something which is not an lvalue (eg. the name of an array!), and it generates an lvalue. So, ptr = &&&&****ptr2; is *not* legal (which is fairly intuitive), however it seems that ptr = &*&*&*&*ptr2; _is_ legal. Whatcha think? paul ----- ------------------------------------------------------------------ | Paul D. Smith | pds@lemming.webo.dg.com | | Data General Corp. | | | Network Services Development | "Pretty Damn S..." | | Open Network Applications Department | | ------------------------------------------------------------------