[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#600888: g++-4.4: [armel, fixed in head] gcc may miscompile "x >> 1"



On 20 October 2010 21:32, Matthias Klose <doko@debian.org> wrote:
On 21.10.2010 01:43, Nick Lewycky wrote:
Package: g++-4.4
Version: 4.4.5-4
Severity: normal


This version of gcc has a bug where code that does a shift-right
by literal one
may be miscompiled, even at -O0. This is breaking my build of llvm and even
a
gcc bootstrap.
>
Fortunately, there's an unintrusive patch for the problem:

  http://gcc.gnu.org/ml/gcc-patches/2010-09/msg01070.html

which has already been accepted into gcc head, but I didn't see it get
applied
to the release branches. Please add this patch as a debian-local change.

when does this trigger?  the testcase succeeds in the debian builds og gcc-4.4 and gcc-4.5, and llvm-2.7 did build too.

I'm using llvm from svn. There's a "make check" failure in test/Assembler/alignstack.ll due to this code in lib/Bitcode/Reader/BitcodeReader.cpp:1192 does:

      bool IsAlignStack = Record[0] >> 1;

where Record[0] is an unsigned long & equal to 3. The resulting IsAlignStack is set to false. While that one instance could be fixed by replacing it with & 2, there's a bunch of other places in the code which also use >> 1 to actually mean shift right, and the clang that's built out of this doesn't work very well at all.

Note that due to the nature of the bug, small changes in the code could affect register layout such that this problem does not manifest. It's entirely possible that a build of llvm 2.8 might not show the same testcase failure but still have problems in other cases.

Nick


Reply to: