std::underlying_type fails in SFINAE situation when it shouldn't

std::underlying_type fails in SFINAE situation when it shouldn't

I can't login to Premier Support, so... Could someone file a bug report about this for me? The following code works when compiled with Visual Studio 2012 (v.11.0), but it fails with Intel C++ Composer XE 2013 (v.13.0.089).

#include <type_traits>

enum Fruit { apple, orange };

template <typename T>
    typename std::enable_if< std::is_enum<T>::value,
typename std::underlying_type<T>::type& >::type underlying(T& enumValue)
    return reinterpret_cast< std::underlying_type<T>::type& >(enumValue);

int main()
    static_assert(std::is_enum<Fruit>::value, "");
    Fruit fruit;
    return 0;

// error : no instance of function template "underlying" matches the argument list
// argument types are: (Fruit)
// ++underlying(fruit);
//   ^

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Thank you for the small example. I have entered DPD200236148 in our internal bug database for this defect.
It seems to be a problem when using the underlying_type type trait with a dependent type.

We will fix this as soon as possible.


Leave a Comment

Please sign in to add a comment. Not a member? Join today