octave-maintainers
[Top][All Lists]
Advanced

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

Re: undefined compound chaining behavior


From: Jordi Gutiérrez Hermoso
Subject: Re: undefined compound chaining behavior
Date: Thu, 12 Jun 2014 08:24:44 -0400

On Wed, 2014-06-11 at 23:33 +0330, Hossein Sajjadi wrote:
> To  show that undefined behavior is propagated from c++ through Octave
> ,it is sufficient to prove that the compound operator that is used in
> Octave is actually the operator that is used in C++.

No, this is not sufficient. What is sufficient is to find UB in the
C++ code, such as an expression like X += X += Y. Thankfully, you
don't have to perform the search yourself, since compilers can do
that. Since the compiler has not found such an expression in C++, it
either does not exist or all compilers tested so far are buggy about
this. Since it seems unlikely that all compilers are buggy, seeing how
they do demonstrably detect this expression in other cases, it is safe
to conclude such an expression does not exist.

> with syntax of bison parser if we write:
> | VAR ADD_EQ exp { $1->value.var += $3; $$ = $1->value.var;     }
> or the same thing such as :
> double op_add_eq ( double& lhs,double rhs){
> lhs=lhs+rhs;
> return lhs;
> }
> 
> there is no difference , and operator in two languages is the same,so
> chaining compound assingnment results in undefined behavior in Octave

What we are observing in Octave is a consequence of the ways we have
defined the operators in C++, but you will observe the same behaviour
in Octave with any compiler and under any threading conditions. There
is no UB.

- Jordi G. H.







reply via email to

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