On Mon, 30 Mar 2020, Martin Liška wrote:

The patch ensures that a deleted new/delete pair has a same context.
That will fix the issue presented in the PR.

DECL_CONTEXT seems good for that example (assuming it is still available in the middle-end), but shouldn't we also check if both are array versions? I can build a similar example by implementing the global operator new[] in terms of operator new and operator delete[] in terms of operator delete. Checking if both are aligned versions could be nice as well. I don't know what others can be relevant, I think we are allowed to mix throw and nothrow, or sized and non-sized versions.

For DECL_CONTEXT, if we use new on a derived class and delete on a base class, I guess it is sensible not to optimize unless devirt / inlining manage to show a matched pair of operators, so your patch looks good here.

I understand this feature is getting rather painful, sorry...

--
Marc Glisse

Reply via email to