Enum signedness
Jan Hubicka
jh@suse.cz
Sat Jul 29 08:18:00 GMT 2000
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);
More information about the Gcc-bugs
mailing list