Re: About GCC4 Optimization

From: Andrew Morton
Date: Sun Mar 25 2007 - 00:31:39 EST


On Sun, 25 Mar 2007 03:42:25 +0000 "yuan cooper" <yuanxjtu@xxxxxxxxxxx> wrote:

> Hi all:
>
> during my work, I found there is a bug with GCC4 O2 optimization.
>
> ---------------------
> float ftmp;
> unsigned long tmp;
> ftmp = 1.0/1024.0;
> tmp = *(unsigned long *)(&ftmp);
> tmp = (tmp >> 11) && 0xFFF;
> ---------------------
>
> if optimization level is O2, gcc will MOV eax to tmp, but current eax has a random value.
> -O is ok and gcc3 with O2 is ok too.
>
>
> I am a kernel newbie, I don't know how to make contributions to janitors, who will help me? It's my first post, any suggestion will be appreciated.

Don't use floating point in kernel code. At all.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/