This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Enum signedness
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com, gcc-bugs at gcc dot gnu dot org
- Subject: Enum signedness
- From: Jan Hubicka <jh at suse dot cz>
- Date: Sat, 29 Jul 2000 17:18:22 +0200
Hi
Currently the comparisons agains enums are unsigned. This has changed from
older gccs and breaks crafty and some other tests in spec2000. For example:
typedef enum {RANK1, RANK2, RANK3, RANK4, RANK5, RANK6, RANK7, RANK8} ranks;
int
main ()
{
int rank = -1;
if (rank >= RANK1)
abort();
}
Aborts currently. I am not sure whether this is correct behaviour or not, but
I believe that enums are signed unless traditional C is used. One of fixes
that looks sensible to me is attached in the patch, but I am really not quite
sure what should be the proper fix.
Sat Jul 29 16:59:00 CEST 2000 Jan Hubicka <jh@suse.cz>
* c-typeck.c (default_conversion): Make enums signed.
*** c-typeck.c.old Sat Jul 29 16:50:17 2000
--- c-typeck.c Sat Jul 29 16:50:59 2000
*************** default_conversion (exp)
*** 904,910 ****
TYPE_PRECISION (integer_type_node)),
((flag_traditional
|| (TYPE_PRECISION (type)
! >= TYPE_PRECISION (integer_type_node)))
&& TREE_UNSIGNED (type)));
return convert (type, exp);
--- 904,910 ----
TYPE_PRECISION (integer_type_node)),
((flag_traditional
|| (TYPE_PRECISION (type)
! > TYPE_PRECISION (integer_type_node)))
&& TREE_UNSIGNED (type)));
return convert (type, exp);