lvalues -> incomplete types

Discussion in 'C Programming' started by Mantorok Redgormor, Feb 6, 2004.

  1. 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
    Mantorok Redgormor, Feb 6, 2004
    #1
    1. Advertising

  2. Mantorok Redgormor

    pete Guest

    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
    pete, Feb 6, 2004
    #2
    1. Advertising

  3. 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.
    Jeremy Yallop, Feb 6, 2004
    #3
  4. Mantorok Redgormor

    pete Guest

    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
    pete, Feb 6, 2004
    #4
  5. Mantorok Redgormor

    Joe Wright Guest

    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 ---
    Joe Wright, Feb 6, 2004
    #5
  6. Mantorok Redgormor

    Jack Klein Guest

    On Fri, 06 Feb 2004 23:49:28 GMT, Joe Wright
    <> 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/~ajo/docs/FAQ-acllc.html
    Jack Klein, Feb 7, 2004
    #6
  7. Mantorok Redgormor

    Joe Wright Guest

    Jack Klein wrote:
    >
    > On Fri, 06 Feb 2004 23:49:28 GMT, Joe Wright
    > <> 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 ---
    Joe Wright, Feb 7, 2004
    #7
  8. Mantorok Redgormor

    pete Guest

    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
    pete, Feb 7, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    23
    Views:
    1,429
    Skarmander
    Sep 21, 2006
  2. Lvalues and Rvalues

    , Oct 14, 2006, in forum: C Programming
    Replies:
    3
    Views:
    351
    SM Ryan
    Oct 14, 2006
  3. jacob navia

    casts and lvalues

    jacob navia, Jun 24, 2007, in forum: C Programming
    Replies:
    68
    Views:
    1,419
    Keith Thompson
    Jun 27, 2007
  4. Replies:
    18
    Views:
    559
    Keith Thompson
    Aug 6, 2008
  5. Nicklas Karlsson

    lvalues and rvalues

    Nicklas Karlsson, Apr 6, 2010, in forum: C Programming
    Replies:
    127
    Views:
    2,604
    Tim Rentsch
    May 5, 2010
Loading...

Share This Page