Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
Announcements
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
7779 Discussions

sfinae bug with intel c++ compiler 15

rnickb
Beginner
249 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
249 Views

Hi rnickb,

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

Thanks,

Shenghong

Walter_D_
Beginner
249 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.

MalReddy_Y_Intel
Employee
249 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

 

Shenghong_G_Intel
249 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

Reply