Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Someone_E_
Beginner
80 Views

Possible bug in icc

I am pretty sure the following program complies to C++ 0x standard. icc however cannot compile it:

 

#include <functional>

struct Node {
    size_t length;
};

template<typename N>
class C {
public:
  size_t longest = 0;
  std::function<void(const N )> f = [this](N node) {
    if(node->length > this->longest) this->longest = node->length;
  };
};

int main() {

  Node n;
  n.length = 5;
  C<Node*> c;
  c.f(&n);
}

The error is:

test_func.cc(12): error: "this" cannot be used inside the body of this lambda
      if(node->length > this->longest) this->longest = node->length;

 

I compile with icc (ICC) 14.0.2 20140120 using  -std=c++11 option

0 Kudos
2 Replies
Judith_W_Intel
Employee
80 Views

 

Yes I think you are correct. Both clang and Microsoft accept this (GNU gives an internal error).

It looks like our compiler gives an error because the use of "this" is not inside a non static member function (which I think is ok here).

I have entered DPD200257106 in our internal tracking database to track this defect. Thank you for bringing it to our attention.

Judy

Kittur_G_Intel
Employee
80 Views

Thanks Judy, I've updated the issue id to the thread for tracking purposes as well....

Reply