[all-commits] [llvm/llvm-project] a7b2a2: [clang] Improve diagnostics around constexpr limit...
Timm Baeder via All-commits
all-commits at lists.llvm.org
Wed Jul 29 00:03:32 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a7b2a20f01681186bb6872c077a52e22632db9ad
https://github.com/llvm/llvm-project/commit/a7b2a20f01681186bb6872c077a52e22632db9ad
Author: Timm Baeder <tbaeder at redhat.com>
Date: 2026-07-29 (Wed, 29 Jul 2026)
Changed paths:
M clang/include/clang/Basic/DiagnosticASTKinds.td
M clang/lib/AST/ByteCode/InterpHelpers.h
M clang/lib/AST/ByteCode/InterpState.cpp
M clang/lib/AST/ByteCode/State.cpp
M clang/lib/AST/ByteCode/State.h
M clang/lib/AST/ExprConstant.cpp
M clang/test/AST/ByteCode/constexpr-steps.cpp
M clang/test/AST/ByteCode/dynalloc-limits.cpp
M clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
M clang/test/SemaCXX/constexpr-steps.cpp
M clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp
M clang/test/SemaCXX/cxx2c-expansion-stmts.cpp
Log Message:
-----------
[clang] Improve diagnostics around constexpr limits (#212091)
1) Mention the limit in the "constexpr evaluation hit maximum step
limit" diagnostic as well
2) Move the "use -fconstexpr-steps" instruction to its own note so we
can reuse it for two different diagnostics
For
```c++
struct S {
constexpr S() {}
};
constexpr S foo[1'500'000] = {};
```
we used to emit
```console
array.cpp:1028:13: error: constexpr variable 'foo' must be initialized by a constant expression
1028 | constexpr S foo[1'500'000] = {};
| ^ ~~
array.cpp:1026:17: note: constexpr evaluation hit maximum step limit; possible infinite loop?
1026 | constexpr S() {}
| ^
array.cpp:1028:31: note: in call to 'S()'
1028 | constexpr S foo[1'500'000] = {};
| ^
```
and now we emit
```console
array.cpp:1028:13: error: constexpr variable 'foo' must be initialized by a constant expression
1028 | constexpr S foo[1'500'000] = {};
| ^ ~~
array.cpp:1026:17: note: constexpr evaluation hit maximum step limit of 1048576; possible infinite loop?
1026 | constexpr S() {}
| ^
array.cpp:1028:31: note: in call to 'S()'
1028 | constexpr S foo[1'500'000] = {};
| ^
array.cpp:1026:17: note: use -fconstexpr-steps= to increase this limit (=0 will remove the limit)
1026 | constexpr S() {}
```
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list