Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

constexpr bug with c++ compiler version 15

rnickb
Beginner
246 Views

The following code compiles fine with clang and gcc but gives this error with icc: 

icc -std=c++11 problem.cpp 

problem.cpp(12): error: expression must have a constant value

    , typename std::enable_if<MyCheck<T>{}>::type

                                        ^

 

compilation aborted for problem.cpp (code 2)

 

#include <type_traits>                                                                              

                                                                                                    

template<class T>                                                                                   

struct MyCheck {                                                                                    

  constexpr operator bool() const {                                                                 

    return sizeof(T) > sizeof(int);                                                                 

  }                                                                                                 

};                                                                                                  

                                                                                                    

template<                                                                                           

    class T                                                                                         

  , typename std::enable_if<MyCheck<T>{}, int>::type                                                

>                                                                                                   

void f() {                                                                                          

}                                                                                                   

                                                                                                    

int main() {                                                                                        

  return 0;                                                                                         

}

0 Kudos
3 Replies
rnickb
Beginner
246 Views

also added as attachment

0 Kudos
Feilong_H_Intel
Employee
246 Views

Hi rnickb,

Thank you for your test case.  I've produced the error on my machine.  I'm entering it to our problem-tracking database.  Engineering team will look into it soon.

Thanks.

0 Kudos
Feilong_H_Intel
Employee
246 Views

Hi rnickb,

This issue has been resolved in 16.0 compiler.  FYI.

Thanks.

0 Kudos
Reply