This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [lto] RFC: How should gimple represent enums?
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Diego Novillo <dnovillo at google dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 12 Mar 2009 17:08:15 +0000 (UTC)
- Subject: Re: [lto] RFC: How should gimple represent enums?
- References: <b798aad50903120936i22274234p2e77a1b4a74be8fe@mail.gmail.com>
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++.
--
Joseph S. Myers
joseph@codesourcery.com