ahatanak accepted this revision. ahatanak added a comment. This revision is now accepted and ready to land.
Sorry, I was misunderstanding the problem. I was trying to understand why the crash goes away if I change the generic lambda to a non-generic one. What I found was that, when the lambda is generic, `captureInBlock` is passed a `CaptureType` that isn't an lvalue reference type and therefore performs copy initialization and sets the copy expression of the Capture to a non-null expression. This happens because `isVariableAlreadyCapturedInScopeInfo` doesn't assign the correct type (which should be an `LValueReferenceType`) to `CaptureType` when the variable is captured by reference. I think this can be fixed if we check whether `CaptureType` is a reference capture in `isVariableAlreadyCapturedInScopeInfo` and, if it is, turn it into an lvalue reference type. ================ Comment at: test/CodeGenCXX/lambda-capturing-block.cpp:1 +// RUN: %clang_cc1 -triple=x86_64-apple-darwin -S -emit-llvm -std=c++17 -fblocks -fcxx-exceptions -o - %s | FileCheck %s + ---------------- I think you can simplify the test case a bit more: - remove -fcxx-exceptions. - remove 'extern "C"'. - remove the derp's move constructor and destructor. - remove the try/catch and just call 'c.cancel' in the function. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D58164/new/ https://reviews.llvm.org/D58164 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits