Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Alexander_M_1
Beginner
134 Views

Intel Compiler bug while deducing template arguments inside decltype

I ran into a problem with the following code, which compiles fine with gcc and clang, but fails with icc 18.0.1:

struct S
{
    template< typename... Ts  >
    auto access( )
    -> int
    {
        return 1;
    }

    template< typename... Ts  >
    auto operator()( Ts&&... )
    -> decltype( access< Ts... >() )
    {
        return access< Ts... >();
    }
};

struct A {};
struct B {};

int main()
{
	S s;
	s( A(), B() );
}

Based on the types A and B the operator() of s shall call the access method of s. In my real world example the return value of access depends on the given template arguments, so I am using decltype to figure it out. However this does not work although it should or does the standard state something different and gcc and clang are just more friendly?

The error from the Intel compiler is:

test.cpp(24): error: no instance of function template "S::operator()" matches the argument list
            argument types are: (A, B)
            object type is: S
        s( A(), B() );
        ^
test.cpp(11): note: this candidate was rejected because at least one template argument could not be deduced
      auto operator()( Ts&&... )
           ^

compilation aborted for test.cpp (code 2)

Best regards,

Alexander Matthes

0 Kudos
2 Replies
Viet_H_Intel
Moderator
134 Views

Hi Alexander,

Thanks for reporting this issue. I'll submit a bug and have it fixed in the next update.

Regards,

Viet

Viet_H_Intel
Moderator
134 Views

Hi Alexander,

I've filed CMPLRS-49623 to track this bug.

Thanks,

Viet

Reply