[clang] [Clang][Sema] Error message refers to `__begin1` with `constexpr` variable in range-based for loop (PR #218145)
Akash Manna via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 26 10:55:34 PDT 2026
================
@@ -501,3 +501,11 @@ namespace SubPtr {
// both-note {{subtracted pointers are not elements of the same array}}
constexpr auto diff8 = &a[1][2].n - (&a[1][2].n + 1);
}
+
+namespace ConstexprForRangeVar {
+ void f() {
+ int arr[] = {1, 2, 3};
+ for (constexpr int a : arr) {} // both-error {{constexpr variable 'a' must be initialized by a constant expression}} \
+ // both-note {{range-based for loop variable is initialized on each iteration from the loop's iterator, whose value is not known at compile time}}
----------------
akash-manna-sky wrote:
dropped that framing; the note now names the begin variable instead.
https://github.com/llvm/llvm-project/pull/218145
More information about the cfe-commits
mailing list