Article View: comp.std.c
Article #56Re: on "use", and the lvalue-ness of string literals
From: Larry Jones
Date: Mon, 02 Nov 1992 22:30
Date: Mon, 02 Nov 1992 22:30
56 lines
2473 bytes
2473 bytes
In article <1992Nov2.162310.10094@ichips.intel.com>, bhoughto@sedona.intel.com (Blair P. Houghton) writes: > First, Jutta Degener and I are having a discussion on the > Standard's use of the verb "to use" in the context of > value contexts. As in 3.2.2.2 where it says: The (nonexistent) value of a void expression (an expression that has type void) shall not be used in any way... or is there some other use of "to use" that I don't remember. > I'm trying to develop a good definition, and it's come > down to a few expression forms. The important > thing to remember is that it's the value, not the > identifier or the location, that is being "used." > > if ( foo ) ...; /* uses `foo' */ > foo; /* does not use `foo' */ > x = foo; /* uses `foo' */ > foo = x; /* does not use `foo' */ I agree, but I think it's much clearer to say *value* of `foo' rather than just `foo'. > I'd say it was merely a matter of whether a side-effect > depends on the value, but `if ( foo ) /* empty */;' does not > have any side effects, but definitely does use the value > of `foo'. (Remember, "issues of optimization are > irrelevant," so the null statement WILL be "executed" > in the "abstract machine.") I think side-effects are a red herring. What's important is whether the value is *used* or not; the semantics in 3.3 Expressions and 3.6 Statements (and possible other subsections) specify where values are used. > "A string literal is a primary expression. > It is an lvalue..." > (ANSI X3.159-1989, sec. 3.3.1 > Primary Expressions, p. 40, l. 13) > > It's an LVALUE. This means that, > > "foo" = "bar"; > > is legal. Right? Nope. Remember that the Standard distinguishes between lvalues and modifiable lvalues. "foo" is an lvalue -- it identifies an object -- but it's an array type and thus is *not* a modifiable lvalue. If it wasn't a lvalue you couldn't take it's address! ---- Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH 45150-2789 513-576-2070 larry.jones@sdrc.com or ...uunet!sdrc!larry.jones I've changed my mind, Hobbes. People are scum. -- Calvin
Technical Details
Message-ID:
<2204@sdrc.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!sdrc!thor!scjonesReferences:
<1992Nov2.162310.10094@ichips.intel.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!sdrc!thor!scjones From: scjones@thor.sdrc.com (Larry Jones) Newsgroups: comp.std.c Subject: Re: on "use", and the lvalue-ness of string literals Message-ID: <2204@sdrc.COM> Date: 2 Nov 92 22:30:13 GMT References: <1992Nov2.162310.10094@ichips.intel.com> Sender: news@sdrc.COM Lines: 56