You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Clang] Fix crash on invalid size in user-defined static_assert message (llvm#89420)
This addresses two problems observed in llvm#89407 wrt user-defined
`static_assert` messages:
1. In `Expr::EvaluateCharRangeAsString`, we were calling `getExtValue()`
instead of `getZExtValue()`, which would assert if a negative or very
large number was returned from `size()`.
2. If the value could not be converted to `std::size_t`, attempting to
diagnose that would crash because `ext_cce_narrowing` was missing two
`%select` cases.
This fixesllvm#89407.
static_assert(true, A{}); // expected-error {{the message in this static assertion is not a constant expression}}
372
+
// expected-note@-1 {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}}
373
+
static_assert(true, B{}); // expected-error {{call to 'size()' evaluates to -1, which cannot be narrowed to type 'unsigned long'}}
374
+
// expected-error@-1 {{the message in this static assertion is not a constant expression}}
375
+
// expected-note@-2 {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}}
376
+
static_assert(true, C{}); // expected-error {{call to 'size()' evaluates to -1, which cannot be narrowed to type 'unsigned long'}}
377
+
// expected-error@-1 {{the message in this static assertion is not a constant expression}}
378
+
// expected-note@-2 {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}}
379
+
static_assert(true, D{}); // expected-error {{call to 'size()' evaluates to 340282366920938463463374607431768211455, which cannot be narrowed to type 'unsigned long'}}
380
+
// expected-error@-1 {{the message in this static assertion is not a constant expression}}
381
+
// expected-note@-2 {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}}
382
+
static_assert(true, E{}); // expected-error {{the message in this static assertion is not a constant expression}}
383
+
// expected-note@-1 {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}}
0 commit comments