[Bug libstdc++/54468] New: type trait is_unsigned<...>::value for C++11 enum class with underlying unsigned type not true

mhcox at bluezoosoftware dot com gcc-bugzilla@gcc.gnu.org
Mon Sep 3 13:34:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54468

             Bug #: 54468
           Summary: type trait is_unsigned<...>::value for C++11 enum
                    class with underlying unsigned type not true
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mhcox@bluezoosoftware.com


The is_unsigned<> type trait is not detecting the underlying signedness of a
C++11 enum class or enum.

The output of:

#include <iostream>
#include <type_traits>

using namespace std;

int main()
{
   enum class enum_class_type: unsigned char
   {
       ENUM_CLASS_VALUE0,
       ENUM_CLASS_VALUE1
   };
   cout << boolalpha << "is_enum<enum_class_type>::value = " <<
is_enum<enum_class_type>::value << endl;
   cout << "is_unsigned<enum_class_type>::value = " <<
is_unsigned<enum_class_type>::value << endl;

   enum enum_type: unsigned char
   {
       ENUM_VALUE0,
       ENUM_VALUE1
   };
   cout << boolalpha << "is_enum<enum_type>::value = " <<
is_enum<enum_type>::value << endl;
   cout << "is_unsigned<enum_type>::value = " << is_unsigned<enum_type>::value
<< endl;
}

should be:

is_enum<enum_class_type>::value = true
is_unsigned<enum_class_type>::value = true
is_enum<enum_type>::value = true
is_unsigned<enum_type>::value = true

but is:

is_enum<enum_class_type>::value = true
is_unsigned<enum_class_type>::value = false
is_enum<enum_type>::value = true
is_unsigned<enum_type>::value = false



More information about the Gcc-bugs mailing list