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

[Bug report] name-resolution inside generic lambdas

In a generic lambdas same names are not found correctly, if in the surrounding scope names from a different namespace are imported:

namespace ns
{
  template <class F>
  void bar2(F f) { f(0); }

  template <class F>
  void bar1(F f)
  {
    bar2(f);                // (1)
  }
}

void foo()
{
  using namespace ns; 
  bar1([&](auto i) {        // (2)
    // using namespace ns;  // (3)
    bar1([&](auto j) {});   // (4)
  }); 
}

int main()
{
  foo();
}

In icc I get the error message

error: identifier "bar1" is undefined

in line (4). See also https://godbolt.org/g/PYzWtw The situation changes if (1) is removed, or if in (3) the names from namespace ns are imported again, or if in (2) and (4) auto is replaced by int. Then, the code compiles fine. Since, this error does not occur in other compilers (Gcc 6.3, CLang 4.0), I assume that this is a bug in the Intel compiler. I tried the compiler version 18.0.1 with flag "-std=c++14"

Best, Simon Praetorius

0 Kudos
1 Reply
Viet_H_Intel
Moderator
149 Views

 

Hi Simon,

Thanks for reporting this issue. I'll keep you posted with any update on the issue.

Regards,

Viet 

Reply