[Bug c/54950] New: Incorrect 32-bit moltiplication on m32c target
m.galante at centrosistemi dot it
gcc-bugzilla@gcc.gnu.org
Wed Oct 17 14:23:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54950
Bug #: 54950
Summary: Incorrect 32-bit moltiplication on m32c target
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: m.galante@centrosistemi.it
m32c-elf-gcc (GCC) 4.7.2 hosted on Windows XP.
This simple program:
/*********** BEGIN ************/
#include <stdio.h>
void multiply(unsigned char byte)
{
printf("%ld\n", 1000000L * byte);
}
main()
{
multiply(2);
return 0;
}
/**************** END ************/
produces the correct result (2000000) only when compiled with -O0:
m32c-elf-gcc -msim -mcpu=m32c -O0 -omul32.out mul32.c
m32c-elf-run mul32.out
If I compile with -O1, -O2, -O3 or -Os I get 33920, which is 2000000 truncated
to 16-bit.
More information about the Gcc-bugs
mailing list