Velocity Reviews > lvalues -> incomplete types

lvalues -> incomplete types

Mantorok Redgormor
Guest
Posts: n/a

 02-06-2004
An lvalue is an expression with an object type or
an incomplete type other than void;53)
if an lvalue does not designate an object when
it is evaluated, the behavior is undefined.

When would one ever use an incomplete type
as an lvalue?

--
nethlek

pete
Guest
Posts: n/a

 02-06-2004
Mantorok Redgormor wrote:
>
> An lvalue is an expression with an object type or
> an incomplete type other than void;53)
> if an lvalue does not designate an object when
> it is evaluated, the behavior is undefined.
>
> When would one ever use an incomplete type
> as an lvalue?

An lvalue isn't how you use an expression.
An lvalue is a kind of expression.

x = y; /* Two lvalues */

--
pete

Jeremy Yallop
Guest
Posts: n/a

 02-06-2004
pete wrote:
> Mantorok Redgormor wrote:
>>
>> An lvalue is an expression with an object type or
>> an incomplete type other than void;53)
>> if an lvalue does not designate an object when
>> it is evaluated, the behavior is undefined.
>>
>> When would one ever use an incomplete type
>> as an lvalue?

>
> An lvalue isn't how you use an expression.
> An lvalue is a kind of expression.
>
> x = y; /* Two lvalues */

Which expressions have incomplete type (other than void) and don't
violate a constraint?

Jeremy.

pete
Guest
Posts: n/a

 02-06-2004
Jeremy Yallop wrote:
>
> pete wrote:
> > Mantorok Redgormor wrote:
> >>
> >> An lvalue is an expression with an object type or
> >> an incomplete type other than void;53)
> >> if an lvalue does not designate an object when
> >> it is evaluated, the behavior is undefined.
> >>
> >> When would one ever use an incomplete type
> >> as an lvalue?

> >
> > An lvalue isn't how you use an expression.
> > An lvalue is a kind of expression.
> >
> > x = y; /* Two lvalues */

>
> Which expressions have incomplete type (other than void) and don't
> violate a constraint?

/* BEGIN new.c */

#include <stdio.h>

extern int array[];

int main(void)
{
int x;

x = array[5000];
return 0;
}

/* END new.c */

--
pete

Joe Wright
Guest
Posts: n/a

 02-06-2004
pete wrote:
>
> Mantorok Redgormor wrote:
> >
> > An lvalue is an expression with an object type or
> > an incomplete type other than void;53)
> > if an lvalue does not designate an object when
> > it is evaluated, the behavior is undefined.
> >
> > When would one ever use an incomplete type
> > as an lvalue?

>
> An lvalue isn't how you use an expression.
> An lvalue is a kind of expression.
>
> x = y; /* Two lvalues */
>

No. Only x might be an lvalue. y is an rvalue.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---

Jack Klein
Guest
Posts: n/a

 02-07-2004
On Fri, 06 Feb 2004 23:49:28 GMT, Joe Wright
<(E-Mail Removed)> wrote in comp.lang.c:

> pete wrote:
> >
> > Mantorok Redgormor wrote:
> > >
> > > An lvalue is an expression with an object type or
> > > an incomplete type other than void;53)
> > > if an lvalue does not designate an object when
> > > it is evaluated, the behavior is undefined.
> > >
> > > When would one ever use an incomplete type
> > > as an lvalue?

> >
> > An lvalue isn't how you use an expression.
> > An lvalue is a kind of expression.
> >
> > x = y; /* Two lvalues */
> >

> No. Only x might be an lvalue. y is an rvalue.

Assuming y is the name of an object of a type that is assignment
convertible to the type of x, rather than a macro or enumerated
constant, than y in this expression is most certainly an lvalue.

The assignment statement performs "lvalue to value" conversion,
by accessing the value of the object. The result of this conversion
is a pure value, and no longer an lvalue, but that does not mean that
y itself is not an lvalue.

Note also that this used to be called "lvalue to rvalue" conversion,
but the term "rvalue" is no longer used in the current C standard
except for a footnote that this formerly used term has been replaced
by the phrase "value of an expression".

Here's the actual quote from 6.3.2.1 Lvalues, arrays, and function
designators, paragraph 2, of the current C standard:

"Except when it is the operand of the sizeof operator, the unary &
operator, the ++ operator, the -- operator, or the left operand of the
.. operator or an assignment operator, an lvalue that does not have
array type is converted to the value stored in the designated
object (and is no longer an lvalue). If the lvalue has qualified type,
the value has the unqualified version of the type of the lvalue;
otherwise, the value has the type of the lvalue. If the lvalue has an
incomplete type and does not have array type, the behavior is
undefined."

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html

Joe Wright
Guest
Posts: n/a

 02-07-2004
Jack Klein wrote:
>
> On Fri, 06 Feb 2004 23:49:28 GMT, Joe Wright
> <(E-Mail Removed)> wrote in comp.lang.c:
>
> > pete wrote:
> > >
> > > Mantorok Redgormor wrote:
> > > >
> > > > An lvalue is an expression with an object type or
> > > > an incomplete type other than void;53)
> > > > if an lvalue does not designate an object when
> > > > it is evaluated, the behavior is undefined.
> > > >
> > > > When would one ever use an incomplete type
> > > > as an lvalue?
> > >
> > > An lvalue isn't how you use an expression.
> > > An lvalue is a kind of expression.
> > >
> > > x = y; /* Two lvalues */
> > >

> > No. Only x might be an lvalue. y is an rvalue.

>
> Assuming y is the name of an object of a type that is assignment
> convertible to the type of x, rather than a macro or enumerated
> constant, than y in this expression is most certainly an lvalue.
>
> The assignment statement performs "lvalue to value" conversion,
> by accessing the value of the object. The result of this conversion
> is a pure value, and no longer an lvalue, but that does not mean that
> y itself is not an lvalue.
>
> Note also that this used to be called "lvalue to rvalue" conversion,
> but the term "rvalue" is no longer used in the current C standard
> except for a footnote that this formerly used term has been replaced
> by the phrase "value of an expression".
>
> Here's the actual quote from 6.3.2.1 Lvalues, arrays, and function
> designators, paragraph 2, of the current C standard:
>
> "Except when it is the operand of the sizeof operator, the unary &
> operator, the ++ operator, the -- operator, or the left operand of the
> . operator or an assignment operator, an lvalue that does not have
> array type is converted to the value stored in the designated
> object (and is no longer an lvalue). If the lvalue has qualified type,
> the value has the unqualified version of the type of the lvalue;
> otherwise, the value has the type of the lvalue. If the lvalue has an
> incomplete type and does not have array type, the behavior is
> undefined."
>

Ok Jack, thanks. Aren't standards wonderful? In the old days, "An object
is a manipulatable region of storage; an lvalue is an expression
referring to an object." Short and sweet. Thanks again.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---

pete
Guest
Posts: n/a

 02-07-2004
Joe Wright wrote:

> Ok Jack, thanks. Aren't standards wonderful?
> In the old days, "An object
> is a manipulatable region of storage; an lvalue is an expression
> referring to an object." Short and sweet.

A dereferenced pointer to object type, is also an lvalue.
That's the kind of lvalue, which gives undefined behavior,
if it doesn't refer to an object when evaluated.
But, they've kept the word "dereferenced" out of the standard, so far.

--
pete