[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 11:39:27 -0400 |
On Thu, 2014-06-12 at 18:45 +0330, Hossein Sajjadi wrote:
> On 6/12/14, Jordi Gutiérrez Hermoso <address@hidden> wrote:
> > 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.
> >
>
> It may be better to see the expression:
> a=1
> a+=a+=4
>
> Duo to right associativity the expression grouped:
> a+=(a+=4)
> The c++ compiler may first evaluates lhs or rhs.
> If lhs evaluated firt "a" evaluated and it's value (1) computed and
> will be stored to be used later,
> then rhs evaluated and value of "a" (1) sums with 4 results 5;
> 5 sums with 1 results 6.
>
> If the compiler decides to evaluate from right to left then the
> result will be 10
This discussion is moot, since the C++ compiler is never evaluating
such an expression in our C++ sources, or we would have seen such a
warning by now. If you can compile Octave and show us a warning such
as the one clang produces,
warning: unsequenced modification and access to 'x'
then we do have UB.
- Jordi G. H.
- Re: undefined compound chaining behavior, (continued)
- Re: undefined compound chaining behavior, Mike Miller, 2014/06/10
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/10
- Re: undefined compound chaining behavior, Jordi Gutiérrez Hermoso, 2014/06/10
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/11
- Re: undefined compound chaining behavior, Jordi Gutiérrez Hermoso, 2014/06/12
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/12
- Re: undefined compound chaining behavior,
Jordi Gutiérrez Hermoso <=
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/12
- Re: undefined compound chaining behavior, John W. Eaton, 2014/06/12
- Re: undefined compound chaining behavior, Richard Crozier, 2014/06/12
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/12
- Re: undefined compound chaining behavior, Jordi Gutiérrez Hermoso, 2014/06/12
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/12
- Re: undefined compound chaining behavior, Jordi Gutiérrez Hermoso, 2014/06/12
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/13
- Re: undefined compound chaining behavior, Richard Crozier, 2014/06/13
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/13