This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/53619] [c++11, regression] wrong capture of "this" in lambda in case of multiple inheritance


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

--- Comment #2 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2012-06-09 17:04:10 UTC ---
an even simpler test

 cat lambda_this2.cpp 
#include<cassert>
struct C {
  int x;
};
struct B {
  int q;
};
struct A : public B , C  {
  void foo();
};

void A::foo() {
  auto k = [this]() {return (void *)(&x);};
  assert(k()==(void *)(&x)); 
}

int main(int l, char **) {
  A a; a.foo();
}

c++ -std=gnu++11 lambda_this2.cpp; ./a.out
a.out: lambda_this2.cpp:14: void A::foo(): Assertion `k()==(void *)(&x)'
failed.
Aborted (core dumped)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]