underlying type of C++ enums
Alexandre Oliva
aoliva@redhat.com
Thu Apr 25 15:01:00 GMT 2002
The underlying type we choose for the following enum is `int', not
`unsigned [long] long' as one might expect from the Standard C++
requirements. (Note that the rules for Standard C are different)
enum foo
{
foo1 = 0,
foo2 = 0xffffffffffffffffULL,
foo3 = 0xf0fffffffffffffeULL,
};
The problem is that, when we look for the min and max enumerators, we
use tree_int_cst_lt, that assumes both operands have the same value
for the UNSIGNED flag. In the case of enum initializers, this
assumption does not hold.
This patch fixes the problem.
I recommend this patch to be considered for GCC 3.1, since it has ABI
affects (it would change sizeof foo from sizeof int to sizeof long
long).
Ok to install?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cp-enum-type.patch
Type: text/x-patch
Size: 2658 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20020425/7c17c585/attachment.bin>
-------------- next part --------------
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer
More information about the Gcc-patches
mailing list