Re: LHS casting

Discussion in 'C Programming' started by Keith Thompson, Mar 3, 2013.

  1. Russell Shaw <rjshawN_o@s_pam.netspace.net.au> writes:
    > gcc-4.7 -pedantic accepts:
    >
    > (*(volatile int *) 0x20) = 0;


    You can't have a cast expression as the LHS of an assignment, because
    a cast doesn't yield an lvalue. But that's what you have here.
    `(volatile int *) 0x20` is a cast expression, and therefore not
    an lvalue. Applying unary `*` to it gives you an lvalue. And a
    parenthesized lvalue is still an lvalue.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    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"
    Keith Thompson, Mar 3, 2013
    #1
    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. Hardeep Rakhra
    Replies:
    3
    Views:
    879
    Hardeep Rakhra
    Feb 7, 2004
  2. Guest
    Replies:
    5
    Views:
    600
    Kai-Uwe Bux
    Jan 31, 2006
  3. Guest
    Replies:
    1
    Views:
    444
    Luke Meyers
    Jan 31, 2006
  4. Eric Sosman

    Re: LHS casting

    Eric Sosman, Mar 3, 2013, in forum: C Programming
    Replies:
    0
    Views:
    144
    Eric Sosman
    Mar 3, 2013
  5. Shao Miller

    Re: LHS casting

    Shao Miller, Mar 3, 2013, in forum: C Programming
    Replies:
    0
    Views:
    153
    Shao Miller
    Mar 3, 2013
Loading...

Share This Page