From patchwork Mon Nov 9 22:38:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 542013 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 87B96140D97 for ; Tue, 10 Nov 2015 09:41:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=wWcZ7KDh; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=HGJgvUraSISo7W39 tMYrKoewDMhBl0F5A2nC9NnyNPp3kkULYsb/USISMQOc+OvGmLdOW4zQueyJ2wIs 8Yte9NirUWAK/0eNol+KjPPw+jdE86UUralOwbAwt4VJX3WHvUtiwCaFPaXpaBJ6 xYrMGteGiqIPRgukN9Jbq9w0e60= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=yW5da6LjlTWY25IjLNiYiB FaV28=; b=wWcZ7KDhPxy8ea6YVxb35CKqK6ohi+YlH1YiPlW7y10j92iCHJIOzd Zy4yLSy2/NV2u+GI214Aguyh4UY21TDRsfG3Gtiwwc4Q46YI5X/qstCfYDWjfuXF dfStzKCK8sSej7/utj8FMn/mP+V1e4qG7bQ50gepjWMlvPq3T6ZGM= Received: (qmail 27285 invoked by alias); 9 Nov 2015 22:41:24 -0000 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 Received: (qmail 27204 invoked by uid 89); 9 Nov 2015 22:41:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 09 Nov 2015 22:41:21 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 535BC330574E for ; Mon, 9 Nov 2015 23:41:18 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6bMKg_KrG6r4 for ; Mon, 9 Nov 2015 23:41:18 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 2E1123305740 for ; Mon, 9 Nov 2015 23:41:18 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix PR middle-end/68259 Date: Mon, 09 Nov 2015 23:38 +0100 Message-ID: <1688683.3FnnDSqby3@polaris> User-Agent: KMail/4.14.9 (Linux/3.16.7-29-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 It's another fallout of the scalar-storage-order merge in the form of a tree checking failure in reverse_storage_order_for_component_p with UBSan. The tree generated by UBSan is arguably invalid (it's a COMPONENT_REF of a REFERENCE_TYPE) but the code already works around invalid trees generated in Fortran (COMPONENT_REF of a VOID_TYPE) and making it more robust is trivial. Tested on x86_64-suse-linux, applied on the mainline as obvious. 2015-11-09 Eric Botcazou PR middle-end/68259 * tree.h (reverse_storage_order_for_component_p) : Check that the type of the first operand is an aggregate type. 2015-11-09 Eric Botcazou * g++.dg/ubsan/pr68259.C: New test. Index: tree.h =================================================================== --- tree.h (revision 230016) +++ tree.h (working copy) @@ -4387,8 +4387,9 @@ reverse_storage_order_for_component_p (t { case ARRAY_REF: case COMPONENT_REF: - /* ??? Fortran can take COMPONENT_REF of a void type. */ - return !VOID_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0))) + /* ??? Fortran can take COMPONENT_REF of a VOID_TYPE. */ + /* ??? UBSan can take COMPONENT_REF of a REFERENCE_TYPE. */ + return AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0))) && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (t, 0))); case BIT_FIELD_REF: