Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the expression (a=b) = k UB?

Is (a = b ) = k undefined behavior if a,b and k are of int type and properly initialised?

thanks

like image 952
Pavan WLA Avatar asked Feb 25 '23 01:02

Pavan WLA


1 Answers

Looks UB to me. a is getting modified more than once b/w two sequence points.

The result of (a=b) is an lvalue1 which is a reference to a

1 The result of the assignment operation is the value stored in the left operand after the assignment has taken place; the result is an lvalue ($5.17/1).

like image 92
Prasoon Saurav Avatar answered Mar 07 '23 06:03

Prasoon Saurav