c/5420: bad code generated with gcc3.1/ia64
David Mosberger
davidm@hpl.hp.com
Thu Jan 17 18:56:00 GMT 2002
>Number: 5420
>Category: c
>Synopsis: bad code generated with gcc3.1/ia64
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Thu Jan 17 18:56:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: David Mosberger
>Release: 3.1 20020117 (experimental)
>Organization:
HP Labs
>Environment:
System: Linux wailua.hpl.hp.com 2.4.17 #2 SMP Thu Jan 17 13:53:26 PST 2002 ia64 unknown
Architecture: ia64
ia64, Linux, ia64
host: ia64-hp-linux-gnu
build: ia64-hp-linux-gnu
target: ia64-hp-linux-gnu
configured with: ../gcc/configure --prefix=/opt/gcc3.1 --host=ia64-hp-linux : (reconfigured)
>Description:
On the attached test program, gcc generates bad code with
an optimization level of -O2. -O works fine.
>How-To-Repeat:
$ gcc -O2 test.c
$ ./a.out
./a.out
dev=1220
dev=1220
This is wrong. The correct output should be:
dev=800
dev=810
>Fix:
The workaround is to drop the optimization level to -O.
<-- test.c --><-- test.c --><-- test.c --><-- test.c -->
typedef struct {
unsigned short value;
} kdev_t;
#define mk_kdev(major, minor) ((kdev_t) { (((major) << 8) + (minor)) } )
#define SD_MAJOR(i) (!(i) ? 8 : 65-1+(i))
#define MKDEV_SD_PARTITION(i) mk_kdev(SD_MAJOR((i) >> 8), (i))
int
main (int argc, char **argv)
{
int idx;
for (idx = 0; idx < 2; ++idx)
printf ("dev=%x\n", MKDEV_SD_PARTITION((idx) << 4).value);
}
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-prs
mailing list