diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-08-25 07:19:41 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-08-25 07:19:41 +0200 |
commit | 61680cfaf1eef26a5953f36ab82a1cc13f9b2f2c (patch) | |
tree | 9f1f1aa3c1f1c81e02feef5969fc2efedad98709 /gcc/cp/semantics.c | |
parent | 9f2f79df19fbfaa1c4be313c2f2b5ce04646433e (diff) | |
download | gcc-61680cfaf1eef26a5953f36ab82a1cc13f9b2f2c.zip gcc-61680cfaf1eef26a5953f36ab82a1cc13f9b2f2c.tar.gz gcc-61680cfaf1eef26a5953f36ab82a1cc13f9b2f2c.tar.bz2 |
c++: Fix up ptr.~PTR () handling [PR96721]
The following testcase is miscompiled, because build_trivial_dtor_call
handles the case when instance is a pointer by adding a clobber to what
the pointer points to (which is desirable e.g. for delete) rather than the
pointer itself. That is I think always desirable behavior for references,
but for pointers for the pseudo dtor case it is not.
2020-08-25 Jakub Jelinek <jakub@redhat.com>
PR c++/96721
* cp-tree.h (build_trivial_dtor_call): Add bool argument defaulted
to false.
* call.c (build_trivial_dtor_call): Add NO_PTR_DEREF argument. If
instance is a pointer and NO_PTR_DEREF is true, clobber the pointer
rather than what it points to.
* semantics.c (finish_call_expr): Call build_trivial_dtor_call with
true as NO_PTR_DEREF.
* g++.dg/opt/flifetime-dse8.C: New test.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r-- | gcc/cp/semantics.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b71ca07..3877a0e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2713,7 +2713,7 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual, denoted by the object expression of the class member access. */ tree ob = TREE_OPERAND (fn, 0); if (obvalue_p (ob)) - result = build_trivial_dtor_call (ob); + result = build_trivial_dtor_call (ob, true); else /* No location to clobber. */ result = convert_to_void (ob, ICV_STATEMENT, complain); |