Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: lvalue types Date: Fri, 02 Mar 2018 16:54:15 -0800 Organization: None to speak of Lines: 53 Message-ID: References: <2b687d74-f559-43a9-9aec-8a1067467ce2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="bc1147ccc842b73bdba534adacdee29b"; logging-data="1711"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ccBVe45i/f1HMwGudY6/K" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:vdpqo8F0TZb+/9rjjROTvXiDXik= sha1:q0a8waTzlV6Nxc+u6yH3hxi96kM= Xref: csiph.com comp.lang.c:127286 supercat@casperkitty.com writes: > On Friday, March 2, 2018 at 1:45:52 PM UTC-6, Keith Thompson wrote: [...] >> You should refresh your memory on what the word "lvalue" actually means >> before you try to change the definition. An lvalue is a kind of >> expression. Specifically, it's an expression that (potentially) >> designates an object. (The word "potentially" was added in C11 to >> ensure that *ptr is considered an lvalue even if ptr is a null pointer >> value when the expression is evaluated.) > > My point is that 6.5p7 uses the term "lvalue expression" rather than > "lvalue", and seems to be talking about something other than the final > type that would be yielded by processing the whole expression. The phrase "lvalue expression" is redundant; the word "expression" could (and probably should) have been omitted. It simply means "an expression that is an lvalue". I can think of no other plausible meaning, since there is exactly zero doubt that an lvalue is a kind of expression. When it talks about the type of the "lvalue expression", it simply means the type of the expression (which is an lvalue). I see no ambiguity, only a missing bullet point about accessing subobjects. >> An expression doesn't "yield" an lvalue. An expression may *be* an >> lvalue. And like any expression, it has a unique and well defined type. > > An expression like someArray[func()].foo cannot identify any particular > object of the element type until it is executed and func() is called. As > such, its behavior is that of an expression which, when evaluated, yields > something that can uniquely identify an object. What terminology would > you suggest to distinguish between something that encapsulates the identity > of a particular object, versus an expression that will identify a [possibly > different] object each time it is executed? I see no need for any such terminology. The identity of the object designated by a given lvalue can vary depending when the lvalue is evaluated. So what? N1570 6.5.2.1p1: An lvalue is an expression (with an object type other than void) that potentially designates an object if an lvalue does not designate an object when it is evaluated, the behavior is undefined. [...] Again, it makes no sense to say that an expression "yields" an lvalue. An lvalue may designate an object. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"