From patchwork Thu Aug 24 12:33:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yvan Roux X-Patchwork-Id: 110909 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp5600774qge; Thu, 24 Aug 2017 05:33:44 -0700 (PDT) X-Received: by 10.99.9.2 with SMTP id 2mr6235045pgj.84.1503578024716; Thu, 24 Aug 2017 05:33:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503578024; cv=none; d=google.com; s=arc-20160816; b=HYuohTUNHWKgBev1dQmjJ+WNQsFTyAf5JplFNggN/KWgG1CiiD8XGOxqIAae8FphzJ tnvGAu1/QygEbga6ADkVG7AtXyu9etf1Pi2mvKu2SjrQ42/65ChhvQttnuVO91/n70Dz +U7TZNCctN3F9oqQ/jI6TCCiiQdxbT9rmJSn5rFt68mfO1ajw7VHmw0yfh+6KzXorVAf MtUjnWTLT66kpg5G04eLlOJkb1UXQpJjlVsMoIR8B9W4Y5U/FOAGOsxT6KBWSUXAoACx BwnlaLq7w9xgAkL18/J3WDal9KNhv5vuq8eYhPLdpMZhkDTe+jJ6HMvLmg/TX+A/eahU shtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:delivered-to:sender :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=hejsSUTl1CKKE5NY5Yx2iPvyEtZ9CG3v0E7drn7yZtA=; b=Ehu2R2H1nIKZSH1x2h1myuvBMXoDdKmKQ4WsI+WBMyk/udiXLMJtAN7nBqH1Uhnoqi Af3HbUPgdxIvQmuLHVWhMeerVq+8NpfgFOnOChLZzkJCpQCok0jSRsC+5LCCvkp+y6sM +IHH8B9SIA5LovYM0AG8olQ6yx/yTf913p9Ax9Z+UU2Lc14oDX+IXF21jVUOFnvpy6GZ iGLWC0zKLJmQ8f/hiSA7W2rxRY9pgQWO8Sc5VnTULORyBUHz7HsTwkFm5kwUEUWMUgYj zsM0V1TR/RQfLLBSvBVkV9AhhhCYxI2yQTIX6YocYglBoQX7ZoG+GuBjjvhv3k/Qp/Po OuQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=A9BwsizV; spf=pass (google.com: domain of gcc-patches-return-460877-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460877-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id h29si2746732pfd.375.2017.08.24.05.33.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Aug 2017 05:33:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-460877-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=A9BwsizV; spf=pass (google.com: domain of gcc-patches-return-460877-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460877-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=p0VfA+VJm2wBKDqQgAeRz9LNQDGwDcwN+jPFM68Eud5zg1 htyNYgeyM4lbEjfJxoADlEXGylP7/rLJRdFw+WmPXm5hDXQQpo/FELTVVrNWLGLo l0mDF2J5OCwlDu+qjFQ7wAN9SwBshI/GP61JVG+y23U7X4pTC6CGBpuk8p9us= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=uYQb5/z3w7XeNjwrLmAqbSZ4BJc=; b=A9BwsizVrChaY4xSUqpA ycLL0kg1+1UXYO+3CL9nVIhMoDrlW9srXa2DS+zpTCIN3L3XpBfrBq4V0uI4mOmX WE5gWnRLB7HLjhegc7Rtuj8947PaTB5MVoSKGsWqLmbhtw0iCKAisdiQo4lerCEA uaCcewVzRcTeIO2xkd2Fw38= Received: (qmail 129870 invoked by alias); 24 Aug 2017 12:33:30 -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 127444 invoked by uid 89); 24 Aug 2017 12:33:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yw0-f179.google.com Received: from mail-yw0-f179.google.com (HELO mail-yw0-f179.google.com) (209.85.161.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 Aug 2017 12:33:27 +0000 Received: by mail-yw0-f179.google.com with SMTP id g74so2533143ywb.3 for ; Thu, 24 Aug 2017 05:33:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=pcHeahxkoBQpZ7HVCa1ho5PfIkwwHdz+wa+bLH6I8Hs=; b=MAuCYQ6dErwIW2vEs4QZ4QBZZQY9AJ6Lj+VIS2KWFovgHSStMqXCYVBUhEkI4iYmx2 ZGJlYuEWtuiH3ZFyPufKDXKSRb2BLoCDaafiNGfledrNIbhQ8nHv9uIlxL+EN0s0C8Tq 7rUJfkxNivvgrQ5vMSJTWtdVmFfcPzvKY/9HkLZ0Uko0dBcfXdvB4vG5+qUKDVq0YF3R ycv+iVKJJuMMmnU2DyBA/bAfBoPNDDRh7r2cbyOsKpj/IjvpIwwRXdh4tLMsz1nBTXMb owc1JKSfQo4Hs4YpNKX89bx9JXyYT5N9Uyga18Ws/zoO5sMCRKXFHoEjaDNYPnHiLmAm ylLw== X-Gm-Message-State: AHYfb5iczZtRV8BIVet/Nk5DqFIVh2kF0G3YlfR0MUgyuNy34Eyvk1Me xiUeKygp5+6PTAmgdXsMmUWEru4J84XBEDeO5w== X-Received: by 10.37.105.131 with SMTP id e125mr5041697ybc.277.1503578005343; Thu, 24 Aug 2017 05:33:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.195.193 with HTTP; Thu, 24 Aug 2017 05:33:24 -0700 (PDT) From: Yvan Roux Date: Thu, 24 Aug 2017 14:33:24 +0200 Message-ID: Subject: [Patch] PR c++/80287 backport on GCC 6 branch To: "gcc-patches@gcc.gnu.org" , Bernd Edlinger , Jason Merrill , Nathan Sidwell X-IsSubscribed: yes Hi, As described in the PR, gcc-6-branch is impacted by this issue. This patch backports the original fix from Bernd and the recently added testcase (which does not rely on c++17 features). https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80287 https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00730.html Bootstrapped and regression tested on x86, ARM and AArch64 targets. Ok for gcc-6-branch ? Thanks, Yvan 2017-08-24 Yvan Roux PR c++/80287 C++ crash with __attribute((may_alias)) Backport from mainline 2017-04-17 Bernd Edlinger PR c++/80287 * class.c (fixup_may_alias): Fix all type variants. gcc/testsuite 2017-08-22 Yvan Roux PR c++/80287 * g++.dg/pr8028.C: New test. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 35deb1e99cd..86e7e003fe4 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1999,12 +1999,14 @@ fixup_type_variants (tree t) static void fixup_may_alias (tree klass) { - tree t; + tree t, v; for (t = TYPE_POINTER_TO (klass); t; t = TYPE_NEXT_PTR_TO (t)) - TYPE_REF_CAN_ALIAS_ALL (t) = true; + for (v = TYPE_MAIN_VARIANT (t); v; v = TYPE_NEXT_VARIANT (v)) + TYPE_REF_CAN_ALIAS_ALL (v) = true; for (t = TYPE_REFERENCE_TO (klass); t; t = TYPE_NEXT_REF_TO (t)) - TYPE_REF_CAN_ALIAS_ALL (t) = true; + for (v = TYPE_MAIN_VARIANT (t); v; v = TYPE_NEXT_VARIANT (v)) + TYPE_REF_CAN_ALIAS_ALL (v) = true; } /* Early variant fixups: we apply attributes at the beginning of the class diff --git a/gcc/testsuite/g++.dg/pr80287.C b/gcc/testsuite/g++.dg/pr80287.C new file mode 100644 index 00000000000..da8d3fab150 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr80287.C @@ -0,0 +1,13 @@ +// PR c++/80287 +// { dg-do compile { target c++11 } } +// { dg-options "-g" } + +struct A { + operator long() {} +} __attribute__((__may_alias__)); + +struct { + A ino; +} a; + +char b = a.ino;