[Bug middle-end/109224] Wmismatched-new-delete false positive with a templated operator new (common with coroutines)
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Dec 21 19:52:50 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109224
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Arsen Arsenovic <arsen@gcc.gnu.org>:
https://gcc.gnu.org/g:7d83a32aacd6005c0c038c74562e35d70f6a77a8
commit r15-6409-g7d83a32aacd6005c0c038c74562e35d70f6a77a8
Author: Arsen ArsenoviÄ <arsen@aarsen.me>
Date: Thu Aug 1 17:38:15 2024 +0200
warn-access: ignore template parameters when matching operator new/delete
[PR109224]
Template parameters on a member operator new cannot affect its member
status nor whether it is a singleton or array operator new, hence, we
can ignore it for purposes of matching. Similar logic applies to the
placement operator delete.
In the PR (and a lot of idiomatic coroutine code generally), operator
new is templated in order to be able to inspect (some of) the arguments
passed to the coroutine, to make allocation-related decisions. However,
the coroutine implementation will not call a placement delete form, so
it cannot get templated. As a result, when demangling, we have an extra
template DEMANGLE_COMPONENT_TEMPLATE around the actual operator new, but
not operator delete. This terminates new_delete_mismatch_p early.
PR middle-end/109224 - Wmismatched-new-delete false positive with a
templated operator new (common with coroutines)
gcc/ChangeLog:
PR middle-end/109224
* gimple-ssa-warn-access.cc (new_delete_mismatch_p): Strip
DEMANGLE_COMPONENT_TEMPLATE from the operator new and operator
after demangling.
gcc/testsuite/ChangeLog:
PR middle-end/109224
* g++.dg/warn/Wmismatched-new-delete-9.C: New test.
More information about the Gcc-bugs
mailing list