&&**
Paul D. Smith
pds at lemming.webo.dg.com
Thu Sep 13 00:19:18 AEST 1990
In some article, brnstnd at 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 at lemming.webo.dg.com |
| Data General Corp. | |
| Network Services Development | "Pretty Damn S..." |
| Open Network Applications Department | |
------------------------------------------------------------------
More information about the Comp.lang.c
mailing list