[Bug c++/115747] [C++26] P3144R2 - Deleting a pointer to an incomplete type should be ill-formed
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jul 2 14:36:39 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115747
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Do you mean something like:
@@ -4114,6 +4114,14 @@ build_vec_delete_1 (location_t loc, tree
if (!COMPLETE_TYPE_P (type))
{
+ if (cxx_dialect > cxx23)
+ {
+ if ((complain & tf_error)
+ && permerror (loc, "operator %<delete []%> used on "
+ "incomplete type"))
+ cxx_incomplete_type_diagnostic (base, type, DK_PERMERROR);
+ return error_mark_node;
+ }
if (complain & tf_warning)
{
auto_diagnostic_group d;
or
@@ -4114,19 +4114,22 @@ build_vec_delete_1 (location_t loc, tree
if (!COMPLETE_TYPE_P (type))
{
- if (complain & tf_warning)
+ if (complain & (cxx_dialect > cxx23 ? tf_error : tf_warning))
{
auto_diagnostic_group d;
- if (warning_at (loc, OPT_Wdelete_incomplete,
- "possible problem detected in invocation of "
- "operator %<delete []%>"))
+ diagnostic_t kind = cxx_dialect > cxx23 ? DK_PERMERROR : DK_WARNING;
+ if (emit_diagnostic (kind,loc, OPT_Wdelete_incomplete,
+ "possible problem detected in invocation of "
+ "operator %<delete []%>"))
{
- cxx_incomplete_type_diagnostic (base, type, DK_WARNING);
+ cxx_incomplete_type_diagnostic (base, type, kind);
inform (loc, "neither the destructor nor the "
"class-specific operator %<delete []%> will be called, "
"even if they are declared when the class is defined");
}
}
+ if (cxx_dialect > cxx23)
+ return error_mark_node;
/* This size won't actually be used. */
size_exp = size_one_node;
goto no_destructor;
or something else? I think the former is fine, the wording of the second
variant is just weird, because it isn't a possible problem, it is strictly
invalid code for C++26 and there is no need to explain what would happen in
that case.
More information about the Gcc-bugs
mailing list