http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53619

--- Comment #1 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 
2012-06-09 16:16:32 UTC ---
reduced a bit showing how the offset is wrongly computed

struct CA {
  int x;
};
struct B {
  virtual ~B(){}
};

struct A : public B , CA  {
  int foo(int);
};


int A::foo(int l) {
  std::cout << "in foo " << x << " " << (void *)(&x) << std::endl;
  auto k = [this](int i) {
    std::cout << "in lambda " << x << " " << (void *)(&x) << std::endl;
    return x+i;
  };
  return k(l); 
}



int main(int l, char **) {
  A a; a.x=1;
  std::cout << a.foo(l) << std::endl;
}

 c++ -O2 -std=gnu++11 lambda_this2.cpp
 ./a.out 
in foo 1 0x7fff6c4de178
in lambda 4198320 0x7fff6c4de170
4198321

Reply via email to