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

Bug report: icpc fe can't handle fold expressions with `using` clause used in SFINAE context

gnaggnoyil
Beginner
1,035 Views

The following code is accepted under gcc 8, gcc 10, clang 10 with `-std=c++17`, and msvc 19.27 with `/std:c++17`:

 

#include <type_traits>

template <typename ...Ts>
using all_of = std::bool_constant<(Ts::value && ...)>;

template <typename T>
struct bar : std::true_type{};

template <typename ...Ts,
        typename = std::enable_if_t<all_of<bar<Ts>...>::value>>
void foo(Ts &&...){}

int main(){
        foo(0, 0, 0, 0);
        return 0;
}

 

And possibly any other release of those compilers would accept it too.

Linux64 icc 19.0.1, 21.1.8 and 21.1.9 with flags `-std=c++17` on the other hand rejects this code:

test1.cpp(14): error: no instance of function template "foo" matches the argument list
            argument types are: (int, int, int, int)
        foo(0, 0, 0, 0);
        ^
test1.cpp(11): note: this candidate was rejected because at least one template argument could not be deduced
  void foo(Ts &&...){}
       ^

compilation aborted for test1.cpp (code 2)

 

(And I think other versions of icc would probably have the same bug too)

Labels (2)
0 Kudos
3 Replies
AbhishekD_Intel
Moderator
1,003 Views

Hi,

 

Thanks for reaching out to us.

We tried your code and we are able to reproduce this issue. So we are forwarding this issue to the concerned team as it seems like a bug with the ICPC compiler.

 

 

Warm Regards,

Abhishek

 

0 Kudos
Viet_H_Intel
Moderator
992 Views

I've reported this issue to our FE team.

Thanks,


0 Kudos
Viet_H_Intel
Moderator
783 Views

This issue is fixed in oneAPI2021.2.

$ icpc -V

Intel(R) C++ Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_000000


I am going to close this thread.


0 Kudos
Reply