[clang] [clang] Remove separate evaluation step for static class member init. (PR #142713)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 6 14:30:53 PDT 2025
================
@@ -143,3 +143,8 @@ namespace fold_initializer {
const float A::f = __builtin_is_constant_evaluated();
static_assert(fold(A::f == 1.0f));
}
+
+struct GH99680 {
+ static const int x = 1/(1-__builtin_is_constant_evaluated()); // expected-error {{in-class initializer for static data member is not a constant expression}} \
+ // expected-note {{division by zero}}
----------------
zygoloid wrote:
@shafik I think you're right based on the current standard wording, but that this is a bug in the wording of the standard. The situation described in [expr.const]/28.5's example is a fallback from constant evaluation of the initializer to runtime evaluation, and that fallback shouldn't be possible for a static const data member. Will ask CWG.
https://github.com/llvm/llvm-project/pull/142713
More information about the cfe-commits
mailing list