Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Dix_Lorenz
Beginner
75 Views

Some lambda problem

Hi,
this is on Windows, compiler update 9. Deep in my code there is this snippet:
[bash]if (!theCellsToPrepare.empty()) { thePrepareGroup.DispatchAsync([=]() { for_each(theCellsToPrepare.begin(), theCellsToPrepare.end(), [=](DLGLTableCell inCell) { auto theCellCache = CalcCache(inCell, true); [/bash] This is inside a class method, "CalcCache" is another method in the class; that call crashes because "this" is "0xcdcdcdcd". I am 100% sure "this" has not been freed by then, it is still a live object and in any case, a pointer to it wouldn't change it's value anyway. Somehow "this" doesn't get copied correctly into the lambda. It's not the lamda inside the lambda, explicitely using "this->CalcCache" also didn't help. This worked:
[bash]if (!theCellsToPrepare.empty()) { auto *theInterior = this; // BUGBUGCOMPILER, shouldn't be necessary thePrepareGroup.DispatchAsync([=]() { for_each(theCellsToPrepare.begin(), theCellsToPrepare.end(), [=](DLGLTableCell inCell) { auto theCellCache = theInterior->CalcCache(inCell, true); [/bash] I am just starting with using lambdas, so I might be wrong. But since the lambdas do capture everything by value, this "fix" should not make any difference whatsoever. Also the original code works on clang (tip of trunk) without any problems. So I believe there is a compiler bug hidden somewhere in there; I haven't tried to create a simple testcase for it, so this is more of an "FYI, there is a bug somewhere" than anything.
0 Kudos
1 Reply
Georg_Z_Intel
Employee
75 Views

Hello,

I just got aware that this is a duplicate to another thread for which we've already been further. Hence I'm going to close this thread and like to forward you to
http://software.intel.com/en-us/forums/showthread.php?t=104862
for the latest status.

Best regards,

Georg Zitzlsberger
Reply