[clang] [Clang] Add regression test for numeric_limits crash without <limits> (#63497) (PR #247436)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 30 21:23:25 PST 2026


https://github.com/pethapixels-create created https://github.com/llvm/llvm-project/pull/247436

## Summary
Adds a build-free regression test for #63497 (crash in `getASTRecordLayout` when `std::numeric_limits` is used without including `<limits>`). Fixed by #94542.

## Test plan
- New file `clang/test/SemaCXX/numeric-limits-no-include-crash.cpp`
- Verified locally with clang 19: `clang++ -x c++ --std=c++20 -fsyntax-only -Xclang -verify` passes (exit 0), producing the expected `implicit instantiation of undefined template` diagnostics with no crash.

Fixes #63497


>From 3bb52e8fa9716abc990ce22b5dfe8356a3c4288e Mon Sep 17 00:00:00 2001
From: pethapixels-create <pethapixels at gmail.com>
Date: Tue, 1 Dec 2026 05:23:13 +0000
Subject: [PATCH] [Clang] Add regression test for PR#94542 / issue #63497
 (numeric_limits crash without <limits>)

---
 .../SemaCXX/numeric-limits-no-include-crash.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 clang/test/SemaCXX/numeric-limits-no-include-crash.cpp

diff --git a/clang/test/SemaCXX/numeric-limits-no-include-crash.cpp b/clang/test/SemaCXX/numeric-limits-no-include-crash.cpp
new file mode 100644
index 0000000000000..7f99d5f5d1f79
--- /dev/null
+++ b/clang/test/SemaCXX/numeric-limits-no-include-crash.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -verify
+// Regression test for issue #63497: using std::numeric_limits without
+// including <limits> used to crash in getASTRecordLayout. Fixed by #94542.
+
+namespace std {
+template <class T> struct numeric_limits; // expected-note 2 {{template is declared here}}
+}
+
+using E = std::numeric_limits<int>;
+
+auto fail(E e) -> decltype(throw e, void()) { // expected-error 2 {{implicit instantiation of undefined template 'std::numeric_limits<int>'}}
+  throw e;
+}
+
+int main() {
+  return 0;
+}



More information about the cfe-commits mailing list