This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/42807] New: constant folding at compile time limited to integers.
- From: "tossit1 at mail15 dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Jan 2010 18:00:23 -0000
- Subject: [Bug c/42807] New: constant folding at compile time limited to integers.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Gnu compiler (latest microchip version with full optimizations) makes the
following error.
unsigned long value;
value=2501*1600;
the result should be 0x3D0F40 instead it is 0x0F40.
The problem is this. The compiler computed the constant 2501*1600 as an
integer, even though it had sufficient information to know that value is a
long, and thus should have automatically promoted the constants in the
multiplication. It assigned the integer value to the long properly, but since
the compiler did the multiply in integer form first, it only got the last half.
postpending 'l' to each constant fixes it, but that should not be necessary, as
the compiler has all the information it needs to properly do the multiply.
--
Summary: constant folding at compile time limited to integers.
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tossit1 at mail15 dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42807