https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66077
Bug ID: 66077
Summary: Right shift calculation error
Product: gcc
Version: 4.4.7
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: mike.jost at hp dot com
Target Milestone: ---
Curious right shift calculation error. I have used this sequence many times in
de Bruijn sequence calc to count trailing zeros. simplified to basic steps. Not
sure if this is a linux VM issue or compiler issue.
This same code works
using Quincy 2205 v1.3 05-Feb-2008
MinGW GCC version 4.2.1 on windows platform
fails with.
version:
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enax
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
Linux VM
$ uname -a
Linux hpnsw019.rose.hp.com 2.6.32-504.12.2.el6.centos.plus.x86_64 #1 SMP Thu
Mar 12 18:39:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
#include <stdio.h>
int main(int argc, char **argv)
{
unsigned long w = 64UL;
unsigned long x = 0xF12B3740UL;
unsigned long y = 0UL;
unsigned long z = 0UL;
unsigned long a = 0UL;
y = (w * 0x07C4ACDDUL); /* = 0xF12B3740UL */
z = y >> 27UL;
a = x >> 27UL;
printf("w = %lu\n",w);
printf("x = 0x%X\n", x);
printf("y = 0x%X\n", y);
printf("z = %lu\n", z);
printf("a = %lu\n", a);
}
output:
w = 64
x = 0xF12B3740
y = 0xF12B3740
z = 62
a = 30
z and a should be the same (30).