Community
cancel
Showing results for 
Search instead for 
Did you mean: 
77 Views

[Bug report] Return type deduction for in-class friend functions

In the following example, the return type of a friend function cannot be deduced:

struct B {};

template <class T>
struct A 
{
  friend auto bar(A const&)
  {
    return B{};
  }
};

int main()
{
  using L = decltype(bar(A<int>{}));
}

When defining bar outside of A it can be deduced, but requires to specify the template parameters for A again. Putting B instead of auto in the return type, the code also compiles fine.

This is related to an old stackoverflow question: https://stackoverflow.com/questions/18931993/return-type-deduction-for-in-class-friend-functions
In the answers it is referred to the standard document N3638. Both, GCC and Clang compile the code without complains. Intel icc 18 results inthe error "cannot deduce return type of function bar"

See also, the compiler explorer output using intel c++ 18: https://godbolt.org/g/69KQTt

0 Kudos
1 Reply
Viet_H_Intel
Moderator
77 Views

Hi Praetorius,

This seems to be a known issue and has been addressed. You will not encounter this issue in the next 18.0 update.

Regards,

Viet 

Reply