Why isn't the result of this cast an lvalue?

后端 未结 4 558
南笙
南笙 2021-01-13 01:25

I need some advice with this strange behavior – lets have this code:

int ** p;

This compiles without any trouble:

p++;
         


        
4条回答
  •  花落未央
    2021-01-13 01:51

    Why isn't the result of this cast an lvalue?

    I draw your attention to section 6.5.4 of the C99 specification, line 4, footnote 86, which states:

    A cast does not yield an lvalue.

    You have a cast.

    The result is not an lvalue.

    The ++ operator requires an lvalue.

    Therefore your program is an error.

提交回复
热议问题