]> git.baikalelectronics.ru Git - kernel.git/commit
fbmon: work around compiler bug in gcc-2.4.2
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 22 Jul 2009 15:49:22 +0000 (08:49 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 22 Jul 2009 15:49:22 +0000 (08:49 -0700)
commit8e6250523b3e2b7cf1c2808e10ab6a5b6164b5a4
tree69fbde0ab59f4ee04cc4169e7f9f63ec55682ea8
parent64ad91c7e3b4f33fd771c9e597b2b9e9cebaf44a
fbmon: work around compiler bug in gcc-2.4.2

There's some odd bug in gcc-4.2 where it miscompiles a simple loop whent
he loop counter is of type 'unsigned char' and it should count to 128.

The compiler will incorrectly decide that a trivial loop like this:

unsigned char i, ...

for (i = 0; i < 128; i++) {
..

is endless, and will compile it to a single instruction that just
branches to itself.

This was triggered by the addition of '-fno-strict-overflow', and we
could play games with compiler versions and go back to '-fwrapv'
instead, but the trivial way to avoid it is to just make the loop
induction variable be an 'int' instead.

Thanks to Krzysztof Oledzki for reporting and testing and to Troy Moure
for digging through assembler differences and finding it.

Reported-and-tested-by: Krzysztof Oledzki <olel@ans.pl>
Found-by: Troy Moure <twmoure@szypr.net>
Gcc-bug-acked-by: Ian Lance Taylor <iant@google.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/video/fbmon.c