[Top][All Lists]

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

[Octave-bug-tracker] [bug #54572] int64 does not saturate correctly in n

From: Rik
Subject: [Octave-bug-tracker] [bug #54572] int64 does not saturate correctly in negative direction
Date: Tue, 28 Aug 2018 16:12:45 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0

Follow-up Comment #14, bug #54572 (project octave):

jwe's test case fails for -O2, but works for other optimization levels.  I
also verified that OCTAVE_HAVE_FAST_INT_OPS must be defined to show the bug. 
There are two places where OCTAVE_HAVE_FAST_INT_OPS is checked.  I ruled out
one with testing.  This leaves this bit of code as the problem:

  static T
  add (T x, T y)
    // The typecasts do nothing, but they are here to prevent an optimizing
    // compiler from interfering.  Also, the signed operations on small types
    // actually return int.
    T u = static_cast<UT> (x) + static_cast<UT> (y);
    T ux = u ^ x;
    T uy = u ^ y;
    if ((ux & uy) < 0)
        u = octave_int_base<T>::max_val () + __signbit (~u);
    return u;

The comment sounds interesting.  It specifically says that the casts are there
to prevent an optimizing compiler from interfering, which it seems like it


Reply to this item at:


  Message sent via Savannah

reply via email to

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