From patchwork Thu Nov 7 13:21:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 289330 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DFABE2C00A0 for ; Fri, 8 Nov 2013 00:23:20 +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=fs6Hgyt9pN459QWrBSqszbqfdEjbO0PHTAWLNvNjitv 5cXS6qpl1FFKZxfs91eWXvpxUUSh3Y2iHQ4RnneQlDOWTEC01Lb9nbToVbuk4z3Y 4O6G5tmFcNhBXKhvX/KXLrc86vX1m1t0gMX/PzVq9EmLOedc9z4ZZtI+l3k1+C7Y = 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=3mABolwBnjZx9S4jT3edFi9u5No=; b=yft5OsaJIiCmr5pfl Fg7egbMFFzbog4eMDrq7CTIEwoQrfbiwdTHnB5Q+sAboQaJQ1TMmNZez00iTVuFr F9TuTY1F6naWPAuXf3pU9eukt+aG3T3PQdChdkLG7GdJZ8E0XiEZ5vkjBSsv9zBk lGEjqwZhyVONQdx3HXfX04cpLI= Received: (qmail 5128 invoked by alias); 7 Nov 2013 13:23:09 -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 5117 invoked by uid 89); 7 Nov 2013 13:23:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPAM_SUBJECT, SPF_PASS, UNPARSEABLE_RELAY autolearn=no version=3.3.2 X-HELO: aserp1040.oracle.com Received: from Unknown (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 07 Nov 2013 13:21:12 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rA7DL4CH029003 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 7 Nov 2013 13:21:04 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rA7DL3dC016549 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 7 Nov 2013 13:21:03 GMT Received: from abhmt109.oracle.com (abhmt109.oracle.com [141.146.116.61]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rA7DL2AH020973; Thu, 7 Nov 2013 13:21:02 GMT Received: from poldo4.casa (/79.45.212.108) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 07 Nov 2013 05:21:02 -0800 Message-ID: <527B93BC.8020101@oracle.com> Date: Thu, 07 Nov 2013 14:21:00 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch/RFC] PR 58176 (ICE with nullptr at -O0 in output_constant) X-IsSubscribed: yes Hi, at -O0 we ICE for this valid testcase in output_constant because NULLPTR_TYPE is not handled. Should I dig further because we never want nullptr to reach varasm? Because otherwise the patchlet works fine, I checked that expand_expr can cope perfectly well with NULLPTR_TYPE as TREE_TYPE of the INTEGER_CST (generally, we are already handling NULLPTR_TYPE in a number of places outside /cp) Thanks, Paolo. //////////////////// Index: testsuite/g++.dg/cpp0x/nullptr30.C =================================================================== --- testsuite/g++.dg/cpp0x/nullptr30.C (revision 0) +++ testsuite/g++.dg/cpp0x/nullptr30.C (working copy) @@ -0,0 +1,40 @@ +// PR c++/58176 +// { dg-do compile { target c++11 } } + +// Nil +struct nil_ { constexpr nil_ () {} }; +constexpr nil_ nil; + +// Cons +template +struct cons_ { + using head_ = H; + using tail_ = T; + + H head; + T tail; + + constexpr cons_() {} + constexpr cons_(H const &h, T const &t) : head(h), tail(t) {} +}; +template +constexpr cons_ cons (H const &h, T const &t = nil) { return +cons_(h,t); } + +// List +template struct list_s; +template +struct list_s { + using type = cons_::type>; +}; +template <> +struct list_s<> { + using type = nil_; +}; +template +using list_ = typename list_s::type; +constexpr nil_ list () { return nil; } +template +constexpr list_ list (H h, T... t) { return cons(h, list(t...)); } + +constexpr auto l1 = list("monkey", 123.4, cons(1, 2), nullptr); Index: varasm.c =================================================================== --- varasm.c (revision 204508) +++ varasm.c (working copy) @@ -4685,6 +4685,7 @@ output_constant (tree exp, unsigned HOST_WIDE_INT case OFFSET_TYPE: case FIXED_POINT_TYPE: case POINTER_BOUNDS_TYPE: + case NULLPTR_TYPE: if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode, EXPAND_INITIALIZER), MIN (size, thissize), align, 0))