Commit d66ab7d1 by Jakub Jelinek Committed by Jakub Jelinek

re PR sanitizer/87095 (UndefinedBehaviorSanitizer vptr false positive with…

re PR sanitizer/87095 (UndefinedBehaviorSanitizer vptr false positive with virtual inheritance only with -fno-sanitize-recover)

	PR c++/87095
	* decl.c (begin_destructor_body): If current_class_type has
	virtual bases and the primary base is nearly empty virtual base,
	voidify clearing of vptr and make it conditional on in-charge
	argument.

	* g++.dg/ubsan/vptr-13.C: New test.

From-SVN: r263967
parent 849ec6ca
2018-08-29 Jakub Jelinek <jakub@redhat.com>
PR c++/87095
* decl.c (begin_destructor_body): If current_class_type has
virtual bases and the primary base is nearly empty virtual base,
voidify clearing of vptr and make it conditional on in-charge
argument.
2018-08-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/85265
......
......@@ -15698,6 +15698,18 @@ begin_destructor_body (void)
tree stmt = cp_build_modify_expr (input_location, vtbl_ptr,
NOP_EXPR, vtbl,
tf_warning_or_error);
/* If the vptr is shared with some virtual nearly empty base,
don't clear it if not in charge, the dtor of the virtual
nearly empty base will do that later. */
if (CLASSTYPE_VBASECLASSES (current_class_type)
&& CLASSTYPE_PRIMARY_BINFO (current_class_type)
&& BINFO_VIRTUAL_P
(CLASSTYPE_PRIMARY_BINFO (current_class_type)))
{
stmt = convert_to_void (stmt, ICV_STATEMENT,
tf_warning_or_error);
stmt = build_if_in_charge (stmt);
}
finish_decl_cleanup (NULL_TREE, stmt);
}
else
......
2018-08-29 Jakub Jelinek <jakub@redhat.com>
PR c++/87095
* g++.dg/ubsan/vptr-13.C: New test.
2018-08-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/85265
......
// PR c++/87095
// { dg-do run }
// { dg-options "-fsanitize=vptr -fno-sanitize-recover=vptr" }
struct A
{
virtual ~A () {}
};
struct B : virtual A {};
struct C : B {};
int
main ()
{
C c;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment