Re: Writing a C Compiler: lvalues

Keith Thompson <kst-u@mib.org>
Wed, 19 May 2010 00:11:32 -0700

          From comp.compilers

Related articles
[4 earlier articles]
Re: Writing a C Compiler: lvalues kst-u@mib.org (Keith Thompson) (2010-05-09)
Re: Writing a C Compiler: lvalues esosman@ieee.org (Eric Sosman) (2010-05-09)
Re: Writing a C Compiler: lvalues stargazer3p14@gmail.com (Stargazer) (2010-05-10)
Re: Writing a C Compiler: lvalues marc@lithia.nl (Marc van Lieshout) (2010-05-16)
Re: Writing a C Compiler: lvalues esosman@ieee.org (Eric Sosman) (2010-05-17)
Re: Writing a C Compiler: lvalues kst-u@mib.org (Keith Thompson) (2010-05-17)
Re: Writing a C Compiler: lvalues kst-u@mib.org (Keith Thompson) (2010-05-19)
Re: Writing a C Compiler: lvalues bartc@freeuk.com (bart.c) (2010-05-19)
Re: Writing a C Compiler: lvalues lawrence.jones@siemens.com (2010-05-19)
Re: Writing a C Compiler: lvalues kst-u@mib.org (Keith Thompson) (2010-05-19)
Re: Writing a C Compiler: lvalues DrDiettrich1@aol.com (Hans-Peter Diettrich) (2010-05-20)
Re: Writing a C Compiler: lvalues s_dubrovich@yahoo.com (2010-05-22)
Re: Writing a C Compiler: lvalues lawrence.jones@siemens.com (2010-05-24)
| List of all articles for this month |
From: Keith Thompson <kst-u@mib.org>
Newsgroups: comp.lang.c,comp.compilers
Date: Wed, 19 May 2010 00:11:32 -0700
Organization: None to speak of
References: 10-05-036 10-05-095 10-05-101
Keywords: C, parse
Posted-Date: 19 May 2010 22:22:36 EDT

Eric Sosman <esosman@ieee.org> writes:
> On 5/16/2010 4:20 PM, Marc van Lieshout wrote:
>>
>> An lvalue is an expression that evaluates to an address, so it *can* be
>> used on the left hand side of an assignment.
>
> That won't quite do. Here are two counter-examples, one an
> expression that evaluates to an address but is not an lvalue:
>
> malloc(42)
>
> ... and one an lvalue that cannot possibly involve an address:
>
> register int x;
> x = 42;
>
> An lvalue (we're talking C here, right?) "is an expression with an
> object type or an incomplete type other than void" (6.3.2.1p1).


Which is a horribly incomplete definition. 42 is an lvalue by
this definition (since int is an object type), but it's clearly
not intended to be an lvalue.


The essence of lvalue-ness is that an lvalue designates an object.
The trick is defining the term so that *ptr remains an lvalue even
if ptr==NULL.


--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.