On Tuesday, October 19, 2021 at 8:20:50 PM UTC-7, Robin Vowels wrote:
> On Wednesday, October 20, 2021 at 8:27:15 AM UTC+11, Lynn McGuire wrote:
> > is following code legal ?
> The fragment is not even legal in PL/I, which does allow multiple
> Its assignments are of the form
> a, b, c, ... z = expression;
Even worse, PL/I allows statements like:
where the first = is an assignment, and the rest are the relational operator.
However, the comma form makes it (more) obvious that it is assigning
one value to all, and not propagation right to left.
In C, and in the Watcom documentation above, the assignments are right
to left, including any conversions done along the way.
In C, if you do:
int i, j;
float x, y;
then y=3.5, and the rest 3, as you expect for right to left assignment,
and no warnings from gcc.
If you do:
then gcc gives a warning on converting the constant.
Java will catch this without a cast, as it is a narrowing conversion.