[cfe-dev] Motivation for scoped enum comparison behavior?

Richard Smith richard at metafoo.co.uk
Tue Oct 22 14:34:14 PDT 2013


On Tue, Oct 22, 2013 at 1:36 PM, Eric Fiselier <eric at efcs.ca> wrote:

> Hi all,
>
> I hope this is the correct mailing list.
>
> I wanted to ask why clang chooses to compare scoped enumerators as if they
> were unsigned numbers, even when the underlying type is signed. For example
>
> enum class E : int
> {
>    neg_one = -1,
>    one = 1;
> };
>
> neg_one > one; // true
>
> What is the motivation for this behavior?
>

This was a bug, and is already fixed. (I can look up the bug number if
you're interested, but in essence the problem was that we were failing to
determine that 'E' is signed.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131022/97c6b9ac/attachment.html>


More information about the cfe-dev mailing list