diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-03-16 08:02:30 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-03-16 08:02:30 +0100 |
commit | 6651c93e42d125b151a4a2631fbb912c8d5a986a (patch) | |
tree | c8ac5eee044e0fcaef9172effa14564e7f342f24 /gcc/cp/cp-ubsan.c | |
parent | 1935f2506e9d4ad4ae4aedb691e5bbd26202ba25 (diff) | |
download | gcc-6651c93e42d125b151a4a2631fbb912c8d5a986a.zip gcc-6651c93e42d125b151a4a2631fbb912c8d5a986a.tar.gz gcc-6651c93e42d125b151a4a2631fbb912c8d5a986a.tar.bz2 |
re PR sanitizer/70147 (testcase from hana testsuite gets miscompiled with -fsanitize=undefined)
PR c++/70147
* cp-ubsan.c (cp_ubsan_dfs_initialize_vtbl_ptrs): Conditionalize
BINFO_VIRTUAL_P vtable clearing on current_in_charge_parm.
* g++.dg/ubsan/pr70147-2.C (C::C): Initialize A base with invalid
method call to i () as argument. Adjust expected output.
From-SVN: r234249
Diffstat (limited to 'gcc/cp/cp-ubsan.c')
-rw-r--r-- | gcc/cp/cp-ubsan.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/cp/cp-ubsan.c b/gcc/cp/cp-ubsan.c index d4759da..75aeeb8 100644 --- a/gcc/cp/cp-ubsan.c +++ b/gcc/cp/cp-ubsan.c @@ -299,8 +299,14 @@ cp_ubsan_dfs_initialize_vtbl_ptrs (tree binfo, void *data) /* Assign NULL to the vptr. */ tree vtbl = build_zero_cst (TREE_TYPE (vtbl_ptr)); - finish_expr_stmt (cp_build_modify_expr (vtbl_ptr, NOP_EXPR, vtbl, - tf_warning_or_error)); + tree stmt = cp_build_modify_expr (vtbl_ptr, NOP_EXPR, vtbl, + tf_warning_or_error); + if (BINFO_VIRTUAL_P (binfo)) + stmt = build3 (COND_EXPR, void_type_node, + build2 (NE_EXPR, boolean_type_node, + current_in_charge_parm, integer_zero_node), + stmt, void_node); + finish_expr_stmt (stmt); } return NULL_TREE; |