[clang] [Clang] Fix assertion failure in getASTRecordLayout for invalid declarations (PR #208153)
Tony Varghese via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 8 20:51:48 PDT 2026
================
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+//
+// Test that explicit template specialization after instantiation
+// is handled gracefully without assertion failure.
+//
+// Before the fix, this code triggered an assertion failure:
+// Assertion failed: !D->isInvalidDecl() && "Cannot get layout of invalid decl!"
+// Location: clang/lib/AST/RecordLayoutBuilder.cpp:3388
+// Exit code: 134 (SIGABRT)
+//
+// After the fix:
+// Clean error messages are reported
+// Exit code: 1
+//
+// The fix adds error handling in getASTRecordLayout() to return a minimal
+// safe layout (1-byte size/alignment) for invalid declarations, allowing
+// error recovery to continue and report all errors.
----------------
tonykuttai wrote:
```suggestion
// Test that explicit template specialization after instantiation
// is handled gracefully without assertion failure.
```
https://github.com/llvm/llvm-project/pull/208153
More information about the cfe-commits
mailing list