// system: core duo, 2.4 GHz, 64bit debian sid, vanilla kernel 2.6.26.2
// I stumbled over this using gcc 4.3.1 (Debian 4.3.1-8)
// compiler switches: -O3 -mssse3
// there were no compiler warnings / errors.

const int32_t nCC_[16] = 
{
        3, 2, 2, 1, 1, 1, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0
};

int32_t Residual4x4( int16_t *pAR, int32_t &nCost )
{
        int32_t nRun = 0;

        for( int i=0 ; i<16 ; ++i )
                if ( const int v = pAR[i] ) {
                        nCost += ( abs(v) > 1 ) ? 16 : nCC_[nRun];
                        nRun = 0;
                } else
                        ++nRun;
}

// the above code calculates nCost uncorrectly (leading to a segfault later on)
// when I use the compiler switch -O2 or replace the conditional assignment by
an if / else
// construct, everything works fine.
// gcc 4.2 works fine too. (-with -O3 -msse2)


-- 
           Summary: conditional evaluation incorrect with -O3
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: erik dot moller at cycos dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37096

Reply via email to