[Bug c++/100495] constexpr virtual destructor incorrectly reports memory leak
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon May 10 13:30:11 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100495
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jason at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2021-05-10
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
constexpr.c (cxx_eval_call_expression) has:
if (DECL_CLONED_FUNCTION_P (fun))
fun = DECL_CLONED_FUNCTION (fun);
and similarly constexpr.c (maybe_save_constexpr_fundef) has:
if (processing_template_decl
|| !DECL_DECLARED_CONSTEXPR_P (fun)
|| cp_function_chain->invalid_constexpr
|| DECL_CLONED_FUNCTION_P (fun))
return;
which means instead of calling during constexpr evaluation the deleting
destructor (_ZN3FooD0Ev) we call the destructor it is cloned from (_ZN3FooD4Ev)
and that means we don't constexpr evaluate the actual delete operator call.
I guess it would be possible to remember
DECL_DELETING_DESTRUCTOR_P (fun) from before the fun = DECL_CLONED_FUNCTION
(fun); and constexpr evaluate a delete operator call, but I'm afraid I have no
idea how this works for constructors or any other cloned function either, how
do we figure out what arguments to bind to e.g. in_chrg argument etc.?
More information about the Gcc-bugs
mailing list