octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: undefined compound chaining behavior


From: Hossein Sajjadi
Subject: Re: undefined compound chaining behavior
Date: Fri, 13 Jun 2014 04:54:14 +0330

>
> No, of course it is not sufficient. Suppose, for a moment, that the
> Octave interpreter written in bison transformed the Octave expression,
>
>     x += x += y
>
> into the following C++ expressions:
>
>    tmp = x += y;
>    x += y;
>
> This is not too far from the truth of how the Octave interpreter
> transforms the Octave statement into C++.
>
> Then even though Octave's operator += is transformed into C++'s
> operator +=, there is no UB. In order to incur UB in C++ in this case,
> you *need* to make the compiler evaluate an expression more or less
> identical to the original Octave expression, not a transformation of
> it.
>
> But if the compiler were evaluating such an expression, it would warn
> (well, at least some compilers would warn), but I have not heard any
> reports of such a warning, therefore etc.
>
> - Jordi G. H.
>
Again we analyse the expression
a=1
a+=(a+=4)
It is shown that the operator in both langauges is the same.
The compiler decides to evaluate the expression from left to right
then result will be 6,
if the compiler decides to evaluate the expression from right to left
the result will be 10.
so the result may be different from an evaluation to evaluation or
session to session or compiler to compiler.
In the other words the result is not stable.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]