This is a c++20 extension as far as I know.
Details
Diff Detail
Event Timeline
clang/lib/AST/Interp/Interp.cpp | ||
---|---|---|
264–270 | The same is true for destructors as well: https://godbolt.org/z/a49aEErz8 |
clang/lib/AST/Interp/Interp.cpp | ||
---|---|---|
264–270 | Oh, good catch, thanks. |
clang/lib/AST/Interp/Interp.cpp | ||
---|---|---|
264–270 | Interesting case: https://godbolt.org/z/5r5fdh9jr Implementation divergence, have to figure out who is correct here. |
clang/lib/AST/Interp/Interp.cpp | ||
---|---|---|
264–270 | I believe clang is correct: https://eel.is/c++draft/expr.const#4.8 |
clang/lib/AST/Interp/Interp.cpp | ||
---|---|---|
264–270 | The output is the same with the new constant interpreter; that case is probably handled before it's constant evaluated. |
clang/lib/AST/Interp/Interp.cpp | ||
---|---|---|
265–269 | Combining predicates; NFC | |
clang/test/AST/Interp/cxx20.cpp | ||
133–142 | I'd feel more comfortable if we had some way to validate that the write to a in both of these cases actually caused the correct value to appear in a. We're just validating that this compiles and doesn't crash, but we're not validating that the actual behavior occurs. How about adding tests like: template <bool Good> struct ctor_test { int a = 0; constexpr ctor_test() { if (Good) a = 10; int local = 100 / a; } }; template <bool Good> struct dtor_test { int a = 0; constexpr dtor_test() = default; constexpr ~dtor_test() { if (Good) a = 10; int local = 100 / a; } }; constexpr ctor_test<true> good_ctor; constexpr dtor_test<true> good_dtor; constexpr ctor_test<false> bad_ctor; constexpr dtor_test<false> bad_dtor; |
Combining predicates; NFC