[clang] [C++] Fix a crash with __thread and dependent types (PR #140542)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon May 19 07:22:31 PDT 2025


================
@@ -14608,6 +14608,10 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
   std::optional<bool> CacheHasConstInit;
   const Expr *CacheCulprit = nullptr;
   auto checkConstInit = [&]() mutable {
+    const Expr *Init = var->getInit();
+    if (Init->isInstantiationDependent())
----------------
erichkeane wrote:

So i did a quick audit of the uses of this, and I think this will cause a crash later. 

line 14724 does `checkForConstantInitialization` if this is true.  

I'm not sure how to get a repro for that, but I think that ends up being wrong. Though 14734 is going to cause a similar problem...


https://github.com/llvm/llvm-project/pull/140542


More information about the cfe-commits mailing list