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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id A80EE3857811 for ; Wed, 25 Nov 2020 16:24:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A80EE3857811 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-157-XR1BViz4Ov-x_FN4bTmA7w-1; Wed, 25 Nov 2020 11:24:50 -0500 X-MC-Unique: XR1BViz4Ov-x_FN4bTmA7w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74719107ACE3 for ; Wed, 25 Nov 2020 16:24:49 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-127.ams2.redhat.com [10.36.113.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE0AA5D9CA; Wed, 25 Nov 2020 16:24:48 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 0APGOlIq1436330 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 25 Nov 2020 17:24:47 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 0APGOkM81436329; Wed, 25 Nov 2020 17:24:46 +0100 Date: Wed, 25 Nov 2020 17:24:46 +0100 From: Jakub Jelinek To: Jonathan Wakely Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c++: v2: Add __builtin_bit_cast to implement std::bit_cast [PR93121] Message-ID: <20201125162446.GI3788@tucnak> Reply-To: Jakub Jelinek References: <20200718185056.GN2363@tucnak> <0dda7918-cc7f-3f3f-64c0-34896ef9e15d@redhat.com> <20201102192107.GH3788@tucnak> <20201125092331.GW3788@tucnak> <20201125103128.GF1312820@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201125103128.GF1312820@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: Wed, 25 Nov 2020 16:25:12 -0000 On Wed, Nov 25, 2020 at 10:31:28AM +0000, Jonathan Wakely via Gcc-patches wrote: > On 25/11/20 10:23 +0100, Jakub Jelinek wrote: > > On Tue, Nov 24, 2020 at 05:31:03PM -0700, Jeff Law wrote: > > > FIrst, do we need to document the new builtin?  > > > > I think for builtins that are only meant for libstdc++ as underlying implementation > > of its documented in the standard APIs we have some cases where we don't > > document them and other cases where we don't. > > And people report bugs when they're not documented. They might want to > know how the built-in is supposed to behave so they can implement the > equivalent in other compilers. Documenting the *intended* behaviour > also makes it clear which behaviours can be relied on, which allows us > to change the result for edge cases or out-of-contract inputs later. > If we don't describe the expected behaviour, then we can't really > blame people for relying on whatever it happens to do today. > > I used to think we don't need to bother documenting them, but I've > been persuaded that it's useful to do it. Ok, so like this? 2020-11-25 Jakub Jelinek PR libstdc++/93121 * doc/extend.texi (__builtin_bit_cast): Document. --- gcc/doc/extend.texi.jj 2020-11-23 17:01:51.986013540 +0100 +++ gcc/doc/extend.texi 2020-11-25 17:21:14.696046005 +0100 @@ -13574,6 +13574,21 @@ have intederminate values and the object bitwise compared to some other object, for example for atomic operations. @end deftypefn +@deftypefn {Built-in Function} @var{type} __builtin_bit_cast (@var{type}, @var{arg}) +The @code{__builtin_bit_cast} function is available only +in C++. The built-in is intended to be used by implementations of +the @code{std::bit_cast} C++ template function. Programs should make +use of the latter function rather than invoking the built-in directly. + +This built-in function allows reinterpreting the bits of the @var{arg} +argument as if it had type @var{type}. @var{type} and the type of the +@var{arg} argument need to be trivially copyable types with the same size. +When manifestly constant-evaluated, it performs extra diagnostics required +for @code{std::bit_cast} and returns a constant expression if @var{arg} +is a constant expression. For more details +refer to the latest revision of the C++ standard. +@end deftypefn + @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c}) @opindex fprofile-arcs You may use @code{__builtin_expect} to provide the compiler with Jakub