Code from http://lkml.org/lkml/2007/11/19/493:
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
int i=2;
if( -10*abs (i-1) == 10*abs(i-1) )
printf ("OMG,-10==10 in linux!\n");
else
printf ("nothing special here\n") ;
return 0 ;
}
GCC miscompiles this, because it thinks that, for builtin abs(),
A*abs(B) is the same as abs(A*B) even if A is negative (this is also
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34130). Patch is available
from
http://gcc.gnu.org/viewcvs/trunk/gcc/fold-const.c?r1=130258&r2=130257&view=patch&pathrev=130258
Expectations on LKML are that distributions should handle this bug
with the same urgency as security vulnerabilities (but this is in fact
worse: one has to recompile almost anything with the new gcc to be
sure that all manifestations of this bug are removed). I.e., this is
an obvious candidate for the errata page, or even LFS-6.3.1 (because
of jhalfs).
--
Alexander E. Patrakov
--
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page