From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26636 invoked by alias); 25 Jan 2013 14:58:16 -0000 Received: (qmail 26548 invoked by uid 48); 25 Jan 2013 14:57:48 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56104] [4.7/4.8 Regression] Wrong "dereferencing type-punned pointer" warning Date: Fri, 25 Jan 2013 14:58:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.3 X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg02374.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56104 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #3 from Jakub Jelinek 2013-01-25 14:57:47 UTC --- Guess the relevant change in the patch is: --- trunk/gcc/cp/typeck.c 2011/07/19 13:28:15 176460 +++ trunk/gcc/cp/typeck.c 2011/07/19 14:01:59 176461 @@ -3078,8 +3078,7 @@ return error_mark_node; } /* ...and then the delta in the PMF. */ - instance_ptr = build2 (POINTER_PLUS_EXPR, TREE_TYPE (instance_ptr), - instance_ptr, fold_convert (sizetype, delta)); + instance_ptr = fold_build_pointer_plus (instance_ptr, delta); /* Hand back the adjusted 'this' argument to our caller. */ *instance_ptrptr = instance_ptr; where we didn't fold the POINTER_PLUS_EXPR in this case before (delta is 0 here), but now we do. The above is followed by: /* Next extract the vtable pointer from the object. */ vtbl = build1 (NOP_EXPR, build_pointer_type (vtbl_ptr_type_node), instance_ptr); vtbl = cp_build_indirect_ref (vtbl, RO_NULL, complain); if (vtbl == error_mark_node) return error_mark_node; and during cp_build_indirect_ref this warns, instance_ptr here is ADDR_EXPR of cc VAR_DECL, and as the class type of cc isn't virtual, it doesn't have a vtable pointer at the beginning.