This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/39488] New: ARM ABI: enum comparison against zero optimized away
- From: "algrant at acm dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Mar 2009 09:23:00 -0000
- Subject: [Bug c/39488] New: ARM ABI: enum comparison against zero optimized away
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
With ARM ABI variant selected by -fno-short-enums the compare shouldn't
be optimized away:
enum RC { X, Y, Z };
int check_error(enum RC a) { return a < 0; }
C 6.3#2 guarantees that any value of the compatible type can be assigned
to and from values of the enumerator type "with no change to the value or
the representation". So if the implementation defines the compatible
type to be a signed type (which ARM ABI -fno-short-enums does in this case,
see AAPCS 7.1.3), objects of the enumerator type can validly have negative
values and the test is not redundant. (Of course, a strictly conforming
program cannot rely on this or any other property of the ABI.)
(Aside: this optimization is valid for C++, following 7.2#6.)
--
Summary: ARM ABI: enum comparison against zero optimized away
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: algrant at acm dot org
GCC target triplet: arm-none-eabi-gcc
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39488