Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Possible bug in icc

$
0
0

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


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>