From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 6F09E3857032 for ; Mon, 10 Aug 2020 15:30:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6F09E3857032 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-147-sH8MdkCtMaCNzDFpismrlQ-1; Mon, 10 Aug 2020 11:30:49 -0400 X-MC-Unique: sH8MdkCtMaCNzDFpismrlQ-1 Received: by mail-qk1-f198.google.com with SMTP id h185so7220688qke.21 for ; Mon, 10 Aug 2020 08:30:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=33A4EKRCXSGtWZCrPszUB1A55KD9dDpHa6ejGoFxBH0=; b=teRpkJOaviQz1zKHdQLsGB5l3tHxAq4/jfKLks7lPZq049RyQEyZkYHnjdJzK9AZYs GO58XQEBuEKQEfwUDbTmjaNX18tZ6LO1VgBQp+WogyHFvWPqqnDnUoj7Dom1zPAYu9fk KqDh25Yf4rrumA++vowGiSH4raQRytyuPLfzO0rVmvWnn7zVL/cQ/dItuOWMrXjv+mvr zhZlhNxU3X/sBAYWhCfsET4OkodFdhScXQkBQTaL7VwlBS4zPv9agik0EiY4pYBSjfkP p34aLLcjpIIn/zu7e0eK1xttLlkbaYSgJcpwvt71xymD2TtypJQec0knY71rbT1neeHX akdw== X-Gm-Message-State: AOAM533J25cjya60ZW9Af5yPmPfEZ1wZ0EpVbitEjpuDLz+nt5rCTVsU 0vO58xCkCxZLg+o2hQYgfim4bKPPxaTvkms2MjxSBM6Na8XpEUd6Hy7URxEAOnPnrr2kta9rWnw BJtbMopDk5ytLRRewkw== X-Received: by 2002:a0c:aedf:: with SMTP id n31mr28364319qvd.16.1597073445813; Mon, 10 Aug 2020 08:30:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv4n6vWeDB8NSMCGV4dfQr1JJqTTT93cKdgJjborxmcXcACpwYbmpnuicbSxCyc97WYpwafg== X-Received: by 2002:a0c:aedf:: with SMTP id n31mr28364270qvd.16.1597073445383; Mon, 10 Aug 2020 08:30:45 -0700 (PDT) Received: from [192.168.1.148] (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id o47sm16423443qtk.19.2020.08.10.08.30.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Aug 2020 08:30:44 -0700 (PDT) Subject: Re: [PATCH] c++; Fix constexpr evaluation of SPACESHIP_EXPR [PR96497] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <20200808092306.GA9984@tucnak> From: Jason Merrill Message-ID: <59eca4ba-980d-b6e4-9469-c763522ca400@redhat.com> Date: Mon, 10 Aug 2020 11:30:44 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200808092306.GA9984@tucnak> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Aug 2020 15:30:52 -0000 On 8/8/20 5:23 AM, Jakub Jelinek wrote: > Hi! > > The following valid testcase is rejected, because cxx_eval_binary_expression > is called on the SPACESHIP_EXPR with lval = true, as the address of the > spaceship needs to be passed to a method call. > After recursing on the operands and calling genericize_spaceship which turns > it into a TARGET_EXPR with initialization, we call cxx_eval_constant_expression > on it which succeeds, but then we fall through into code that will > VERIFY_CONSTANT (r) which FAILs because it is an address of a variable. Rather > than avoiding that for lval = true and SPACESHIP_EXPR, the patch just tail > calls cxx_eval_constant_expression - I believe that call should perform all > the needed verifications. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk (and > later for 10.3)? OK. > 2020-08-08 Jakub Jelinek > > PR c++/96497 > * constexpr.c (cxx_eval_binary_expression): For SPACESHIP_EXPR, tail > call cxx_eval_constant_expression after genericize_spaceship to avoid > undesirable further VERIFY_CONSTANT. > > * g++.dg/cpp2a/spaceship-constexpr3.C: New test. > > --- gcc/cp/constexpr.c.jj 2020-08-06 11:35:12.997122440 +0200 > +++ gcc/cp/constexpr.c 2020-08-07 13:30:28.732376843 +0200 > @@ -3085,8 +3085,8 @@ cxx_eval_binary_expression (const conste > else if (code == SPACESHIP_EXPR) > { > r = genericize_spaceship (type, lhs, rhs); > - r = cxx_eval_constant_expression (ctx, r, lval, non_constant_p, > - overflow_p); > + return cxx_eval_constant_expression (ctx, r, lval, non_constant_p, > + overflow_p); > } > > if (r == NULL_TREE) > --- gcc/testsuite/g++.dg/cpp2a/spaceship-constexpr3.C.jj 2020-08-07 13:37:34.883410112 +0200 > +++ gcc/testsuite/g++.dg/cpp2a/spaceship-constexpr3.C 2020-08-07 13:38:09.988918586 +0200 > @@ -0,0 +1,7 @@ > +// PR c++/96497 > +// { dg-do compile { target c++20 } } > + > +#include > + > +static_assert(std::partial_ordering(std::strong_ordering::less) < 0); > +static_assert(std::partial_ordering(1 <=> 2) < 0); > > Jakub >