

The “l” in the “lvalue” stands for something on the left side of the (=) operator. You will get this error message as a result of an expression not producing an lvalue (value on the left side of an assignment). What Causes Expression Must Be a Modifiable Lvalue

Unary-expression assignment-operator assignment-exression


Logical-OR-expression ? expression : conditional-expression ".Īn extract from Annex B follows below: unary-expression: The reason why it does not work is that a cast does not produce an lvalue ( ISO/ANSI 9899-1990 6.3.4 and Annex B which describes the syntax of C).įrom ISO/ANSI 9899-1990 6.3.4, cast operators, footnote 44: "A cast does not yield an lvalue. You can rewrite it to: void f (void *ptr) The following example fails: void f (void *ptr) The best way is probably to rework the types so that the cast do not appear in the first place, if possible.Īn alternative is to use a temporary variable of the desired type. There are a couple of ways to rework the code to avoid this error message. This message occurs because a cast does not produce an lvalue (that is, a value that can be used on the left side of an assignment).Īlso note that a casted expression that is used with the * operator does produce an lvalue, which is why the following is OK: void f (void * ptr) You may encounter the following message if you move code to another version of the IAR C/C++ Compiler: Error: expression must be a modifiable lvalue
