================ @@ -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:
I also think this outcome is pretty surprising: https://godbolt.org/z/cobb3Px5Y The new behavior seems like what we ought to be doing, even if the old behavior is the one the rules appear to require. All other implementations seem to be checking whether the variable is constant-initialized, not whether its initializer is a constant expression. https://github.com/llvm/llvm-project/pull/142713 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits