https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64455

            Bug ID: 64455
           Summary: A constexpr variable template can't be used with
                    enable_if
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com
                CC: jason at redhat dot com

#include <type_traits>

template<typename Type>
constexpr bool IsType = true;

template<class T>
struct X {
    typedef typename std::enable_if<IsType<T>,T>::type type;
};

int main()
{
   X<int>::type t;
}

dionne.cpp:8:37: error: the value of ‘IsType<T>’ is not usable in a constant
expression
     typedef typename std::enable_if<IsType<T>,T>::type type;
                                     ^
dionne.cpp:4:16: note: ‘IsType<T>’ used in its own initializer
 constexpr bool IsType = true;
                ^
dionne.cpp:8:48: error: the value of ‘IsType<T>’ is not usable in a constant
expression
     typedef typename std::enable_if<IsType<T>,T>::type type;
                                                ^
dionne.cpp:4:16: note: ‘IsType<T>’ used in its own initializer
 constexpr bool IsType = true;
                ^
dionne.cpp:8:48: note: in template argument for type ‘bool’ 
     typedef typename std::enable_if<IsType<T>,T>::type type;
                                                ^

Clang accepts the code.

Reply via email to