[clang] [Clang] Deleting an incomplete enum type is not an error (PR #118455)
A. Jiang via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 12 00:47:35 PST 2024
================
@@ -540,6 +540,14 @@ namespace PR10504 {
void f(A *x) { delete x; } // expected-warning {{delete called on 'PR10504::A' that is abstract but has non-virtual destructor}}
}
+#if __cplusplus >= 201103L
+enum GH99278_1 { // expected-note {{definition of 'GH99278_1' is not complete until the closing '}'}}
+ zero = decltype(delete static_cast<GH99278_1*>(nullptr), 0){}
----------------
frederick-vs-ja wrote:
If one attempts to evaluate such a weird delete-expression, there would be initially UB because it's impossible to `new` an object of an incomplete enum type. However, the UB would be definitely transformed into constant evaluation failure, becaue such an enum type only incomplete in the enum body, where every evaluation must be within the constant evaluation of some enumerator.
https://github.com/llvm/llvm-project/pull/118455
More information about the cfe-commits
mailing list