Alexander E. Patrakov wrote:
> 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).

Don't panic.  The combination of a constant times abs(something) is
rare.  I saw three instances in the kernel source and the constant was
positive in all cases.

However, we do need to address this, but it is not an emergency.  An
errata to 6.3 and an update to -dev is appropriate though.  The first
step is to put an appropriate patch out.  We may need more than one: one
for gcc-4.2.2 and one for gcc-4.1.2. (or should we do this with a sed?)

Incorporating the patch in -dev is easy enough, but how should we phrase
the errata page?

  -- Bruce


-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to