Re: LHS casting

Discussion in 'C Programming' started by Eric Sosman, Mar 3, 2013.

  1. Eric Sosman

    Eric Sosman Guest

    On 3/3/2013 8:40 AM, Russell Shaw wrote:
    > Hi,
    > gcc-4.7 -pedantic accepts:
    >
    > (*(volatile int *) 0x20) = 0;
    >
    >
    > I fail to see how in N1570:
    >
    > assignment-expression:
    > conditional-expression
    > unary-expression assignment-operator assignment-expression
    >
    > unary-expression:
    > postfix-expression
    > ++ unary-expression
    > -- unary-expression
    > unary-operator cast-expression
    > sizeof unary-expression
    > sizeof ( type-name )
    > _Alignof ( type-name )
    >
    > unary-operator: one of
    > & * + - ~ !
    >
    > cast-expression:
    > unary-expression
    > ( type-name ) cast-expression
    >
    >
    > I can't see any extension in "info gcc".


    If it's the extra set of parentheses that troubles you,
    here's how they vanish:

    assignment-expression:
    unary-expression assignment-operator assignment-expression

    unary-expression:
    postfix-expression

    postfix-expression:
    primary-expression

    primary-expression:
    ( expression )

    Assuming that the `expression' in the final production can
    be any of the more specialized kinds of expression (if there's
    an explicit production to that effect I've overlooked it, but I
    feel safe in relying on 6.5.1p5), the redundant parentheses have
    been accounted for and you've got the equivalent of

    *(volatile int*) 0x20 = 0;

    If that's still a puzzlement, please describe your puzzlement
    at greater length.

    --
    Eric Sosman
    d
    Eric Sosman, 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:
    880
    Hardeep Rakhra
    Feb 7, 2004
  2. Guest
    Replies:
    5
    Views:
    600
    Kai-Uwe Bux
    Jan 31, 2006
  3. Guest
    Replies:
    1
    Views:
    446
    Luke Meyers
    Jan 31, 2006
  4. Shao Miller

    Re: LHS casting

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

    Re: LHS casting

    Keith Thompson, Mar 3, 2013, in forum: C Programming
    Replies:
    0
    Views:
    143
    Keith Thompson
    Mar 3, 2013
Loading...

Share This Page