From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa36.google.com (mail-vk1-xa36.google.com [IPv6:2607:f8b0:4864:20::a36]) by sourceware.org (Postfix) with ESMTPS id 91884385800F for ; Mon, 28 Dec 2020 20:50:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 91884385800F Received: by mail-vk1-xa36.google.com with SMTP id q66so2567287vke.0 for ; Mon, 28 Dec 2020 12:50:01 -0800 (PST) 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=xibQGEtcMSLgNF3GYhef9hO7wmcH7JeEinupcU2jpgE=; b=rsmxV3WcFfk7mLoriScmYq1FtR4vEBPbvyJ+tpOy1ZaOACwemvUtytMfn0XBZE31BJ Gd4lN+GwfrWLDOmnLXy27ZqV48qNSkqg5JVAYtcQ23FotkOGRDDEiFRH/7Qf6Db3s1pw ypIzuBcF9RZIGiT62WPJlWf4HuKT9/mfmNUxnQWrVjgsYuEZfXjol8RUGjiKX1/KZyon YEwR9CODjtrUnY0TREO6ZIeytPOIib1v5UnJaPcmVSbA3JaXWbxCTczNrRVMLfV2tGwH RNIcCo+8YyvtSz1FiseekK+NEcArbnZL50b8wo7Lttf6hK4qdwLZmtbS+ltcZAG8cf5C +fVw== X-Gm-Message-State: AOAM533uiZ5PoCuurMawp9QkOjBV5deD+5dMg+j9s3jze39NsrI6GfMV JoO9wQR7QnWPvqvoyf6VJNPESDsO3YLI649tRHs= X-Google-Smtp-Source: ABdhPJxGTe1GwO+y/X3v1yMi/voKFa3jswp2k3gAoPe48pLbJbTSfqgjNRCV03H797Li/gEHrd0wJyONzYbhgk94Iwg= X-Received: by 2002:a1f:9888:: with SMTP id a130mr30370138vke.21.1609188601119; Mon, 28 Dec 2020 12:50:01 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Josh Marshall Date: Mon, 28 Dec 2020 15:49:50 -0500 Message-ID: Subject: Re: Should reinterpret_cast be constexpr? To: Jonathan Wakely Cc: "libstdc++" X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Dec 2020 20:50:03 -0000 Is this in master? If so, I'll just merge it in. On Mon, Dec 28, 2020 at 3:47 PM Jonathan Wakely wrote: > On Mon, 28 Dec 2020 at 20:33, Jonathan Wakely > wrote: > > > > On Mon, 28 Dec 2020 at 19:51, Josh Marshall via Libstdc++ > > wrote: > > > > > > Hello all, > > > > > > From the test error `libstdc++-v3/include/bits/stl_vector.h:1837: > error: > > > 'reinterpret_cast' is not a constant expression` and the documentation > at > > > https://en.cppreference.com/w/cpp/language/reinterpret_cast , is > > > `reinterpret_cast()` not constexpr in error? > > > > No, it's not an error. reinterpret_cast is not allowed in constant > expressions. > > This patch replaces the use of reinterpret_cast with an alternative > using C++20 features: > > diff --git a/libstdc++-v3/include/bits/vector.tcc > b/libstdc++-v3/include/bits/vector.tcc > index 27e63388feb..93b2ccc02e3 100644 > --- a/libstdc++-v3/include/bits/vector.tcc > +++ b/libstdc++-v3/include/bits/vector.tcc > @@ -516,9 +516,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER > { > #if __cplusplus < 201103L > value_type __x_copy = __x; > -#else > +#elif ! __cpp_lib_make_obj_using_allocator > _Temporary_value __tmp(this, __x); > value_type& __x_copy = __tmp._M_val(); > +#else > + value_type __x_copy = std::make_from_tuple( > + std::uses_allocator_construction_args( > + _M_get_Tp_allocator(), __x)); > #endif > const size_type __elems_after = end() - __position; > pointer __old_finish(this->_M_impl._M_finish); >