This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Optimize based on possible enum class values?


On 19 May 2016 at 02:52, lh mouse wrote:
> -fstrict-enums
>
> This option is for C++ only.

In this example the enumeration type has a fixed underlying type, so
the valid values of the enumeration are all the valid values of the
underlying type, which allows 0-255. It can't assume that there isn't
code that does:

E e = E{255};

So -fstrict-enums isn't enough to tell the compiler that only the
values 0, 1 and 2 will be used.

As others have replied, __builtin_unreachable() can be used for that.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]