Commit 1a161cd7 by Martin Sebor Committed by Martin Sebor

Fix PR c++/68711 - [6 regression] SEGV on an invalid offsetof of a member

of a virtual base.

gcc/testsuite/ChangeLog:
	* g++.dg/other/offsetof8.C: New test.

gcc/cp/ChangeLog:
	* typeck.c (build_class_member_access_expr): Strip NOPs before
        testing a potentially null operand for equality to zero.

From-SVN: r231437
parent 9ba300b1
2015-12-08 Martin Sebor <msebor@redhat.com>
PR c++/68711
* typeck.c (build_class_member_access_expr): Strip NOPs before
testing a potentially null operand for equality to zero.
2015-12-07 Jakub Jelinek <jakub@redhat.com>
PR c++/68760
......
......@@ -2358,8 +2358,11 @@ build_class_member_access_expr (cp_expr object, tree member,
int type_quals;
tree member_type;
null_object_p = (INDIRECT_REF_P (object)
&& integer_zerop (TREE_OPERAND (object, 0)));
if (INDIRECT_REF_P (object))
null_object_p =
integer_zerop (tree_strip_nop_conversions (TREE_OPERAND (object, 0)));
else
null_object_p = false;
/* Convert OBJECT to the type of MEMBER. */
if (!same_type_p (TYPE_MAIN_VARIANT (object_type),
......
2015-12-08 Martin Sebor <msebor@redhat.com>
PR c++/68711
* g++.dg/other/offsetof8.C: New test.
2015-12-08 Nathan Sidwell <nathan@acm.org>
* gcc.target/nvptx/trailing-init.c: New.
......
// PR c++/68711 - [5 regression] SEGV on an invalid offsetof of a member
// of a virtual base
// { dg-do compile }
struct A { int i; };
struct B: virtual A { };
int a[] = {
!&((B*)0)->i, // { dg-error "invalid access to non-static data member" }
__builtin_offsetof (B, i) // { dg-error "invalid access to non-static" }
};
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