This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/54950] New: Incorrect 32-bit moltiplication on m32c target
- From: "m.galante at centrosistemi dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 17 Oct 2012 14:23:13 +0000
- Subject: [Bug c/54950] New: Incorrect 32-bit moltiplication on m32c target
- Auto-submitted: auto-generated
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.