From patchwork Tue Sep 27 00:33:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 116525 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]) by ozlabs.org (Postfix) with SMTP id 2EBADB6F7E for ; Tue, 27 Sep 2011 10:33:31 +1000 (EST) Received: (qmail 25094 invoked by alias); 27 Sep 2011 00:33:29 -0000 Received: (qmail 25085 invoked by uid 22791); 27 Sep 2011 00:33:28 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Sep 2011 00:33:12 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8R0XBvk004731 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 26 Sep 2011 20:33:11 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p8R0XBCF030615 for ; Mon, 26 Sep 2011 20:33:11 -0400 Received: from [0.0.0.0] ([10.3.113.3]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p8R0X99o014413 for ; Mon, 26 Sep 2011 20:33:10 -0400 Message-ID: <4E8119C5.5030708@redhat.com> Date: Mon, 26 Sep 2011 20:33:09 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:6.0.2) Gecko/20110906 Thunderbird/6.0.2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/50508 (ICE on constexpr &&) 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 cxx_eval_logical_expression was assuming that a folded first operand of && would be either boolean_true_node or boolean_false_node, but in fact it can be a constant with a typedef of bool, which doesn't compare equal with ==. So we should use tree_int_cst_equal to compare them instead. Tested x86_64-pc-linux-gnu, applying to trunk. commit 75fff91977aadc3ba784553b881a8e5222308194 Author: Jason Merrill Date: Mon Sep 26 17:28:27 2011 -0400 PR c++/50508 * semantics.c (cxx_eval_logical_expression): Use tree_int_cst_equal rather than ==. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 19ecbee..89c76d5 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -6680,9 +6680,9 @@ cxx_eval_logical_expression (const constexpr_call *call, tree t, allow_non_constant, addr, non_constant_p); VERIFY_CONSTANT (lhs); - if (lhs == bailout_value) + if (tree_int_cst_equal (lhs, bailout_value)) return lhs; - gcc_assert (lhs == continue_value); + gcc_assert (tree_int_cst_equal (lhs, continue_value)); r = cxx_eval_constant_expression (call, TREE_OPERAND (t, 1), allow_non_constant, addr, non_constant_p); VERIFY_CONSTANT (r); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-typedef1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-typedef1.C new file mode 100644 index 0000000..2719e3a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-typedef1.C @@ -0,0 +1,11 @@ +// PR c++/50508 +// { dg-options -std=c++0x } + +template + struct integral_constant { + typedef T value_type; + constexpr operator value_type() { return true; } + }; + +static constexpr bool value = integral_constant() + && true;