From patchwork Tue Feb 18 16:32:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 321553 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 D20852C00CE for ; Wed, 19 Feb 2014 03:33:31 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=O2jlyiIsLx1euZA8QpcSmKERX5p37VaS9HQsWQVfB52 NOKgB4jUwN+4/Q8bLqKklS+EwkGSgu37hmy0HGKi9tX5bw3xWu7GHOAevts5MZ3o 3nr470sxnZm1gK2b0cRiCehpXk/NOWVKAC+kRzoxZAf0TgD8WPq5ve8duHoNbhts = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=AbOz39oJ1KXxiLy82jDG/Tzx0Tw=; b=Zv1dLBgep5i9DAWCT 0aRW9XSuL+dvuXqb7NwYyPhhmYULC2+e9VeVpuIb9c6aPCHVYs0AWIrS976pca0q lUz9rBPIYkUKuv+TX4ms8qquQY+EJ2FMOCcr1zImSYGEu6nCauQFLssSdo9nNmRl yoQt53PWuELdW9LYGwVn3OUvXo= Received: (qmail 26736 invoked by alias); 18 Feb 2014 16:33:22 -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 26723 invoked by uid 89); 18 Feb 2014 16:33:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FSL_NEW_HELO_USER, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 18 Feb 2014 16:33:10 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s1IGX7Zm007994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Feb 2014 16:33:08 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s1IGX6jt018945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 18 Feb 2014 16:33:07 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s1IGX6QQ018919; Tue, 18 Feb 2014 16:33:06 GMT Received: from [192.168.1.4] (/79.53.235.47) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 18 Feb 2014 08:33:05 -0800 Message-ID: <53038B36.6000103@oracle.com> Date: Tue, 18 Feb 2014 17:32:54 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 60225 X-IsSubscribed: yes Hi, as noticed by Marc, this ICE on invalid regression is essentially due to the fact that ensure_literal_type_for_constexpr_object, at variance with literal_type_p, doesn't use strip_array_types, thus, in: if (CLASS_TYPE_P (type) && !COMPLETE_TYPE_P (complete_type (type))) /* Don't complain here, we'll complain about incompleteness when we try to initialize the variable. */; else if (!literal_type_p (type)) doesn't look through ARRAY_TYPEs and ends up calling literal_type_p, which asserts COMPLETE_TYPE_P (t) which ICEs for the testcase at issue. I'm proposing restoring the consistency in the below obvious way. Tested x86_64-linux. Thanks, Paolo. /////////////////// /cp 2014-02-18 Paolo Carlini PR c++/60225 * semantics.c (ensure_literal_type_for_constexpr_object): Use strip_array_types. /testsuite 2014-02-18 Paolo Carlini PR c++/60225 * g++.dg/cpp0x/constexpr-ice10.C: New. Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 207837) +++ cp/semantics.c (working copy) @@ -7380,7 +7380,8 @@ ensure_literal_type_for_constexpr_object (tree dec if (VAR_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl) && !processing_template_decl) { - if (CLASS_TYPE_P (type) && !COMPLETE_TYPE_P (complete_type (type))) + tree stype = strip_array_types (type); + if (CLASS_TYPE_P (stype) && !COMPLETE_TYPE_P (complete_type (stype))) /* Don't complain here, we'll complain about incompleteness when we try to initialize the variable. */; else if (!literal_type_p (type)) Index: testsuite/g++.dg/cpp0x/constexpr-ice10.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-ice10.C (revision 0) +++ testsuite/g++.dg/cpp0x/constexpr-ice10.C (working copy) @@ -0,0 +1,8 @@ +// PR c++/60225 +// { dg-do compile { target c++11 } } + +struct A +{ + constexpr A() {} + static constexpr A a[2] = {}; // { dg-error "incomplete" } +};