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

template substitution bug with default template arguments

rnickb
Beginner
180 Views

The following code compiles fine with gcc and clang but gives an error with icc 2016.

#include <utility>                                                                 
                                                                                   
struct A {                                                                         
  using value_type = double;                                                       
};                                                                                 
                                                                                   
struct K {                                                                         
  template<class T, class V = typename T::value_type>                              
  auto require(T&& x) -> std::true_type;                                           
};                                                                                 
                                                                                   
template<                                                                          
    class X , class Y,                                                             
    typename R = decltype(std::declval<X>().template require<Y>(                   
        std::declval<Y>()))                                                        
    >                                                                              
constexpr bool g() {                                                               
  return R::value;                                                                 
}                                                                                  
                                                                                   
int main() {                                                                       
  g<K, A>();                                                                       
  return 0;                                                                        
} 

 

0 Kudos
1 Reply
Shenghong_G_Intel
180 Views

Thank you for reporting the issue to us.

I've reproduced the issue with 16.0 beta and v15.0 compiler. I'll file the issue to dev team.

Thanks,

Shenghong

0 Kudos
Reply