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

sfinae bug with intel c++ compiler 15

rnickb
Beginner
358 Views

Following code (also attached)  compiles fine with clang gcc but fails with an error with icc.

 

#include <iostream>                                                                                 

                                                                                                    

struct MyIndex : std::integral_constant<int, -1> {};                                                

                                                                                                    

struct Dimension {                                                                                  

  using Dynamic = MyIndex;                                                                          

};                                                                                                  

                                                                                                    

template<class T, T Key>                                                                            

constexpr bool make_true2(const std::integral_constant<T, Key>&)                                    

{                                                                                                   

  return 1;                                                                                         

}                                                                                                   

                                                                                                    

template<int I>                                                                                     

constexpr int make_true() {                                                                         

  return make_true2(Dimension::Dynamic());                                                          

}                                                                                                   

                                                                                                    

template<                                                                                           

    int I                                                                                           

  , typename std::enable_if<make_true<I>(), int>::type = 0                                          

>                                                                                                   

int myfunc() {                                                                                      

  return 9;                                                                                         

}                                                                                                   

                                                                                                    

int main() {                                                                                        

  std::cout << myfunc<0>() << std::endl;                                                            

  return 0;                                                                                         

}                                                                                                 

0 Kudos
4 Replies
Shenghong_G_Intel
358 Views

Hi rnickb,

I've reproduced the issue and submitted to dev team to fix. Thank you very much.

Thanks,

Shenghong

0 Kudos
Walter_D_
Beginner
358 Views

Any progress on this one? I have a similar issue (icc 15.0.0.090) aborts compilation claiming error, or (if changed the code somewhat) crashes with ICE (c++/4.8.1/type_traits(1766): interal error: assertion failed: lower_constant: bad kind (shared/cfe/edgcpfe/lower_il.c, line 5804).

Walter.

0 Kudos
MalReddy_Y_Intel
Employee
358 Views

Dev team has proposed below workaround:

Change the code as shown below:

template<
    int I
#ifdef OK
  , typename std::enable_if<make_true2(Dimension::Dynamic()), int>::type = 0
#else
  , typename std::enable_if<make_true<I>(), int>::type = 0
#endif
 

Thanks,

Reddy

 

0 Kudos
Shenghong_G_Intel
358 Views

@Walter D.

If possible, you may provide your test case, so that we can check whether they are same root cause.

For the issue reported in this thread, it is fixed in mainline.

Thanks,

Shenghong

0 Kudos
Reply