From patchwork Thu Apr 12 15:16:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 152093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 1520AB70A3 for ; Fri, 13 Apr 2012 01:20:57 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1334848858; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=XOfG5pJBlPyqkCfe7ukj EvW5WyI=; b=RcRHTjV+my9VHsYktgUj4++WJM6Sd+I7EnA3uCFSl2XwiJe67XfK 9PHf5xe4cFNGRnlwhfA8gEKzJl7PEfd+UuhmDEHDvTwC338S1QXXGFqajsMfs/HG H88YCTutrKLL5cfSt80ZtasWLaQPYIDwKamblH22KOeDAKQZox5PmZ4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=cP1bNr0IHj+IitNkOgD/szKiJvqktUZL3kmIuUdrKdTthwnnJeGF4QMlOtifzY lG4q/gSJWyvcHlhrSZrg7n0LehhQnS+y4NK0eB5tDSzHVJKVGQE9PvrAWxci6eA4 qqj61NaZt+6J8Gwdqmx+kfsJ9IYaUJ6V2oHHeb/tlxzMI=; Received: (qmail 7825 invoked by alias); 12 Apr 2012 15:20:34 -0000 Received: (qmail 7782 invoked by uid 22791); 12 Apr 2012 15:20:29 -0000 X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Apr 2012 15:16:52 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 14D3394373; Thu, 12 Apr 2012 17:16:51 +0200 (CEST) Date: Thu, 12 Apr 2012 17:16:50 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Cc: "Joseph S. Myers" Subject: [PATCH][C] Fix PR52549 Message-ID: MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This fixes PR52549 - we are running into an overzealous assert that wants to make sure we don't have PLUS_EXPR on pointers. But that code does not really check this and falls foul of the conversion removal code right before it that transforms (void *)(a + b) to a + b. Fixed as follows. Bootstrap and regtest pending on x86_64-unknown-linux-gnu. Ok? Thanks, Richard. 2012-04-12 Richard Guenther PR c/52549 * c-typeck.c (pointer_diff): Remove bogus assert. * gcc.dg/pr52549.c: New testcase. Index: gcc/c-typeck.c =================================================================== --- gcc/c-typeck.c (revision 186373) +++ gcc/c-typeck.c (working copy) @@ -3446,8 +3446,6 @@ pointer_diff (location_t loc, tree op0, else con1 = op1; - gcc_assert (TREE_CODE (con0) != PLUS_EXPR - && TREE_CODE (con1) != PLUS_EXPR); if (TREE_CODE (con0) == POINTER_PLUS_EXPR) { lit0 = TREE_OPERAND (con0, 1); Index: gcc/testsuite/gcc.dg/pr52549.c =================================================================== --- gcc/testsuite/gcc.dg/pr52549.c (revision 0) +++ gcc/testsuite/gcc.dg/pr52549.c (revision 0) @@ -0,0 +1,6 @@ +/* { dg-do compile } */ + +_mark (long obj, int i, char *a) +{ + (char *)&(((long *)(obj)) [i]) - a; +}