From patchwork Wed Dec 13 10:32:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 847920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-469106-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="P21w+Vc6"; dkim-atps=neutral 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 3yxY8n1fwHz9s72 for ; Wed, 13 Dec 2017 21:39:20 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=ldQR3dMhTuQSoIE4VEHiuG1AL5DMN61R6FkXEwCUw+tHysG4kh YNBxoYbjWQI7gb058+ch0lr3QWNkackWJOiPEm0bNUPfpokZR5QW9b+Fphai5XVk X17qxHF6JnyF0AMJ0KLDomhnR4qLxv8suLd5DhgjUsVdOknYEc7jO47KM= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=9sO839J3NmjzRGTMoBObCZteeLc=; b=P21w+Vc6pg4/54lFB9dh 9QNDWkL0DbCaYY2mt3pkcRqWdB6odQWRlfeBzR+PwsO/cY5qtD8qgNio348JnYoN 2Xf+P8YR1mWVpabWaNTqNTOubLW92Me4JRgcDBXETzfXlTTl3yriik3EcHCLUhYF dPt8QlwEM0OzYj9XFYKMoI0= Received: (qmail 110418 invoked by alias); 13 Dec 2017 10:39:11 -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 110403 invoked by uid 89); 13 Dec 2017 10:39:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Dec 2017 10:39:09 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vBDAbHSM165737; Wed, 13 Dec 2017 10:39:04 GMT Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2eu2kdg0p5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Dec 2017 10:39:03 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vBDAWvD2012481 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Dec 2017 10:32:57 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vBDAWuXN013541; Wed, 13 Dec 2017 10:32:56 GMT Received: from [192.168.1.4] (/87.3.196.15) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 13 Dec 2017 02:32:56 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Nathan Sidwell , Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 81061 ("[7/8 Regression] ICE modifying read-only variable") Message-ID: <978b70fd-2c32-33c0-2697-92bdead883a0@oracle.com> Date: Wed, 13 Dec 2017 11:32:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8743 signatures=668646 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712130153 X-IsSubscribed: yes Hi, in this simple error recovery regression we ICE during gimplification after sensible diagnostic about assigning to a read-only location. The problem can be avoided by simply returning immediately error_mark_node upon cxx_readonly_error - the rest of the function does the same, ie, doesn't try to proceed when complain & tf_error. I also noticed that clang appears to behave in the same way for this error. Tested x86_64-linux. Thanks, Paolo //////////////////////// /cp 2017-12-13 Paolo Carlini PR c++/81061 * typeck.c (cp_build_modify_expr): Upon cxx_readonly_error immediately return error_mark_node. /testsuite 2017-12-13 Paolo Carlini PR c++/81061 * g++.dg/other/const5.C: New. Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 255602) +++ cp/typeck.c (working copy) @@ -8037,8 +8037,7 @@ cp_build_modify_expr (location_t loc, tree lhs, en { if (complain & tf_error) cxx_readonly_error (lhs, lv_assign); - else - return error_mark_node; + return error_mark_node; } /* If storing into a structure or union member, it may have been given a Index: testsuite/g++.dg/other/const5.C =================================================================== --- testsuite/g++.dg/other/const5.C (nonexistent) +++ testsuite/g++.dg/other/const5.C (working copy) @@ -0,0 +1,8 @@ +// PR c++/81061 + +const int i = 0; + +void foo() +{ + (0, i) = 1; // { dg-error "read-only" } +}