https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/174193
This is an error case that results in a null Record, so don't crash later in that case. Fixes #173941 >From b7eeec23675d1b4e8e30a6d21fc1ec0ad167ee88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Fri, 2 Jan 2026 11:03:42 +0100 Subject: [PATCH] [clang][bytecode] Check for null Record This is an error case that results in a null Record, so don't crash later in that case. Fixes #173941 --- clang/lib/AST/ByteCode/Compiler.cpp | 2 ++ clang/test/AST/ByteCode/cxx03.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 4daab0702f147..67980676dcd30 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -3258,6 +3258,8 @@ bool Compiler<Emitter>::VisitCXXConstructExpr(const CXXConstructExpr *E) { bool ZeroInit = E->requiresZeroInitialization(); if (ZeroInit) { const Record *R = getRecord(E->getType()); + if (!R) + return false; if (!this->visitZeroRecordInitializer(R, E)) return false; diff --git a/clang/test/AST/ByteCode/cxx03.cpp b/clang/test/AST/ByteCode/cxx03.cpp index 58d7f3632082d..ff81ed04e8334 100644 --- a/clang/test/AST/ByteCode/cxx03.cpp +++ b/clang/test/AST/ByteCode/cxx03.cpp @@ -46,3 +46,13 @@ struct S { vi4b w; }; const int s = S().w[1]; + +namespace NullRecord { + struct S { + int arr[1024 * 1024 * 1024]; + s = {1, {2}}; // both-error {{a type specifier is required for all declarations}} \ + // both-warning {{default member initializer for non-static data member is a C++11 extension}} + }; + + S s[2] = {}; +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
