From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id B3A513896C23 for ; Thu, 10 Jun 2021 10:43:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B3A513896C23 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-58-kJJwIhwGP4yqmK0oBKSvsw-1; Thu, 10 Jun 2021 06:43:51 -0400 X-MC-Unique: kJJwIhwGP4yqmK0oBKSvsw-1 Received: by mail-wm1-f69.google.com with SMTP id g14-20020a05600c4eceb02901b609849650so3202833wmq.6 for ; Thu, 10 Jun 2021 03:43:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E3EY87wjZjGXI2nOyMHOFB5mgQboSHaJfDxnsX3yeC4=; b=jQUqjXNxxuJoDQD8ZfIwpu/+KeZl0Ea2PvNbc0+1QTS4y3fzn2DZq1YPEecYNR+ZAA MHYjyUFrlz1He1ALawLB82ChUrKG/1XHrOstYeD6Xfr9JRmUWjqqKkpuaQskmZkqtyYU lSCMdyfRWPclN9k78DcZgVGHvex/0gbtDCINzMmsgTUnGRjqoZ6B8NDBZDs63MX2FMru Ed0rs5tbjiuGPzmwzoqnQLj6rnAHggEFWGb6L4ELJLNu3ZD9xejmL7SbSZnkDHr8Nsdm 3YVH87jCKOQdNg+6QSU408wgDyKVCn7b0PjxaPN7eto7m5W/MLYKVroFy3fd1VTjl7vh 7hBw== X-Gm-Message-State: AOAM533zjp1F7wOU8Zct7PqwsFaAA7dGgdK1OHcwA81sHOZ5whvfus49 +LJiyJih3TZgufiw5j7XzbUyMmuhwD/A/waxVHQJEWedjxYftVhROoRdfuvmezjI/Sed8qoOZtJ adSLzF4zKFjD5ChIxIcUdJ1PT8cJa7hjoBw== X-Received: by 2002:a05:600c:354f:: with SMTP id i15mr12924478wmq.131.1623321830130; Thu, 10 Jun 2021 03:43:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFeGTZO7s0M1BEyshY3i3aRdUtjzbxoINmKvWV+ss48e4OaLQ8q9K1hj6Inud1tIoR7odOaSrb5FEOi6yNzJ4= X-Received: by 2002:a05:600c:354f:: with SMTP id i15mr12924459wmq.131.1623321829925; Thu, 10 Jun 2021 03:43:49 -0700 (PDT) MIME-Version: 1.0 References: <20210610083416.GC7746@tucnak> <20210610103434.GE7746@tucnak> In-Reply-To: <20210610103434.GE7746@tucnak> From: Jonathan Wakely Date: Thu, 10 Jun 2021 11:43:39 +0100 Message-ID: Subject: Re: [PATCH] c++: Add C++23 consteval if support - P1938R3 [PR100974] To: Jakub Jelinek Cc: Jason Merrill , gcc Patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, 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: Thu, 10 Jun 2021 10:43:53 -0000 On Thu, 10 Jun 2021 at 11:34, Jakub Jelinek wrote: > > On Thu, Jun 10, 2021 at 11:24:43AM +0100, Jonathan Wakely wrote: > > > And I'm not changing the libstdc++ side, where perhaps we could change > > > std::is_constant_evaluated definition for > > > #ifdef __cpp_if_consteval > > > case to if consteval { return true; } else { return false; } > > > but we need to keep it defined to __builtin_is_constant_evaluated () > > > for C++20 or older. > > > > Is there any advantage to changing that (cheaper for GCC to evaluate?) > > I guess compile-time lost in the noise. > > > or should we just continue to use the __builtin unconditionally? > > > > I suppose it's theoretically possible that there could be a non-GCC > > compiler where defined(__cpp_if_consteval) is true but > > __has_builtin(__builtin_is_constant_evaluated) is false. > > Up to you. The wording says Equivalent to > if consteval { return true; } else { return false; } > and return __builtin_is_constant_evaluated (); is equivalent to that. > > Perhaps some people could appreciate to see it literally there, but we Those people can write their own pure-C++23 library then ;-) > can't use it for C++20 (due to the -Wpedantic warnings or -pedantic-errors Yeah. > errors) and for C++17 and earlier (consteval is not a keyword). std::is_constant_evaluated isn't defined for C++17 and earlier, so in C++14 and C++17 code we have to use the builtin directly (and for C++11 constexpr is so limited that there are no uses for it). I think we should just leave it as-is, and revisit if a good reason arises in future.