On Thu, Mar 12, 2009 at 12:08 PM, Joseph S. Myers
<jos...@codesourcery.com> wrote:
> On Thu, 12 Mar 2009, Diego Novillo wrote:
>
>> Since C treats enums as ints, the maximum value is always INT_MAX
>> regardless of how many values are declared.  So the question is, how
>> should we lower enums into gimple?
>>
>> The temptation is to use C++'s limits, but I'm concerned that may
>> produce confusion somewhere down the line with the optimizers or other
>> diagnostics.  Or should we use C's notion and treat them as ints?
>
> In C an enum type is always compatible with and represented the same as
> some integer type, so using C++ limits could result in miscompilation of C
> code using enums; if int is the type chosen, a variable of the enum type
> may legitimately hold any value of type int, unlike in C++.

In addition to that, C++0x has the notion of 'class enum', which
among other things, let user specify the underlying integral type
(and this is per enum-definition basis).  In anticipation to that, as I
suspect that LTO would have to encode the underlying integral
limits for each enum.

-- Gaby

Reply via email to