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.129.124]) by sourceware.org (Postfix) with ESMTPS id 1582A3858C52 for ; Fri, 23 Sep 2022 14:43:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1582A3858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663944210; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iYIgW/G9qjycINKj3TbkwxTuka5P2ykgCa1Hq+RSUkI=; b=XwPQib5ECp1SgaN9CeZaj4cNs1wVRTNN3xIVuJlRDpV6CK0dce1L0dvliCmkpHyeQONlIh kxGjvFEga2u8oKlyIjCPnEFFphQma0Id0RjmVm1lCtPIs4nV7Z01df6gIRrKnHUHllIc5f naXcgCZoJ6jmbq4yODK/aIcvHRiN4Lk= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-623-k1Tq-J4wPNGr1HyEpeYVmg-1; Fri, 23 Sep 2022 10:43:29 -0400 X-MC-Unique: k1Tq-J4wPNGr1HyEpeYVmg-1 Received: by mail-qk1-f197.google.com with SMTP id de16-20020a05620a371000b006ceb92bc740so154444qkb.15 for ; Fri, 23 Sep 2022 07:43:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=iYIgW/G9qjycINKj3TbkwxTuka5P2ykgCa1Hq+RSUkI=; b=37QwtG4dNM1L7BgQrNI44Pz/lTdcSpyxNFd27A8eb+OP0ebH/hQ4yLKfXOKxhiT4Vv sz2nOfkzPlQ2Z8yX+H2zLXhfGjWfTOdWQjm2wseNr+gf6B98AyBMB1NcYp6qjfmN+Tks R2a5Pa8RWHrVilVzmZxZr/RAOIRbQ1Avl6dtqof6QbRGAls8mxnGwXaZVr+ml9/p2xtN MLBSbgDqM8toFbesEczhkWqxQuz0MDo4f2n2RFf+r1+1QuBZALmTPdLlZqod0zYWdboM JtFLNZpLj7ordtnWWAfHvY53YupuD4syZmxO+Od2YbNGY/+bO2mv3STRfQefRamWlLG2 J24g== X-Gm-Message-State: ACrzQf22C5vrylA9TGkPtYsbi4KtWtFzYskS7jEqVsfZtgSFZXiBC7eu OJGxOzYdLzHtR28xfjIktOIXcG5sge+E+G2Q/xuidTZl623WPNsTbz3nWKA5pW3ExFgeZFNJ7Vz fE3oGnS0f8grKvVCbfpTudrMQ96iIH4Q= X-Received: by 2002:a37:3c5:0:b0:6ce:3f31:e019 with SMTP id 188-20020a3703c5000000b006ce3f31e019mr5994262qkd.498.1663944209194; Fri, 23 Sep 2022 07:43:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5YftZ7bAhZi7/JV+fzH2zMYmQoKRC7Rdytfczy4cvC10GJCeWeYgmGuWkCrAlJQ0hapJwJyPLsWspFrnNq87Q= X-Received: by 2002:a37:3c5:0:b0:6ce:3f31:e019 with SMTP id 188-20020a3703c5000000b006ce3f31e019mr5994254qkd.498.1663944208999; Fri, 23 Sep 2022 07:43:28 -0700 (PDT) MIME-Version: 1.0 References: <20220922133900.142238-1-polacek@redhat.com> In-Reply-To: From: Jonathan Wakely Date: Fri, 23 Sep 2022 15:43:18 +0100 Message-ID: Subject: Re: [PATCH] c++: Implement __is_{nothrow_,}convertible [PR106784] To: Marek Polacek Cc: Jason Merrill , GCC Patches , "libstdc++" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, 23 Sept 2022 at 15:34, Marek Polacek wrote: > > On Thu, Sep 22, 2022 at 06:14:44PM -0400, Jason Merrill wrote: > > On 9/22/22 09:39, Marek Polacek wrote: > > > To improve compile times, the C++ library could use compiler built-ins > > > rather than implementing std::is_convertible (and _nothrow) as class > > > templates. This patch adds the built-ins. We already have > > > __is_constructible and __is_assignable, and the nothrow forms of those. > > > > > > Microsoft (and clang, for compatibility) also provide an alias called > > > __is_convertible_to. I did not add it, but it would be trivial to do > > > so. > > > > > > I noticed that our __is_assignable doesn't implement the "Access checks > > > are performed as if from a context unrelated to either type" requirement, > > > therefore std::is_assignable / __is_assignable give two different results > > > here: > > > > > > class S { > > > operator int(); > > > friend void g(); // #1 > > > }; > > > > > > void > > > g () > > > { > > > // #1 doesn't matter > > > static_assert(std::is_assignable::value, ""); > > > static_assert(__is_assignable(int&, S), ""); > > > } > > > > > > This is not a problem if __is_assignable is not meant to be used by > > > the users. > > > > That's fine, it's not. > > Okay then. libstdc++ needs to make sure then that it's handled right. That's fine, the type traits in libstdc++ are always "a context unrelated to either type", unless users do something idiotic like declare std::is_assignable as a friend. https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1339r1.pdf wants to explicitly say that's idiotic.