libstdc++: Change return type of std::bit_width to int (LWG 3656)
libstdc++-v3/ChangeLog: * doc/html/manual/bugs.html: Regenerate. * doc/xml/manual/intro.xml: Document LWG 3656 change. * include/std/bit (__bit_width, bit_width): Return int. * testsuite/26_numerics/bit/bit.pow.two/lwg3656.cc: New test.
This commit is contained in:
parent
3892251498
commit
4581328022
4 changed files with 30 additions and 2 deletions
|
@ -619,4 +619,8 @@
|
|||
<span class="bold"><strong><code class="code">path::lexically_relative</code> is confused by trailing slashes
|
||||
</strong></span>
|
||||
</span></dt><dd><p>Implement the fix for trailing slashes.
|
||||
</p></dd><dt><a id="manual.bugs.dr3656"></a><span class="term"><a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#3656" target="_top">3656</a>:
|
||||
<span class="bold"><strong>Inconsistent bit operations returning a count
|
||||
</strong></span>
|
||||
</span></dt><dd><p>Changed <code class="code">bit_width</code> to return <code class="code">int</code>.
|
||||
</p></dd></dl></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="license.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="status.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="setup.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">License </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 2. Setup</td></tr></table></div></body></html>
|
|
@ -1308,6 +1308,13 @@ requirements of the license of GCC.
|
|||
<listitem><para>Implement the fix for trailing slashes.
|
||||
</para></listitem></varlistentry>
|
||||
|
||||
<varlistentry xml:id="manual.bugs.dr3656"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#3656">3656</link>:
|
||||
<emphasis role="bold">Inconsistent bit operations returning a count
|
||||
</emphasis>
|
||||
</term>
|
||||
<listitem><para>Changed <code>bit_width</code> to return <code>int</code>.
|
||||
</para></listitem></varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</section>
|
||||
|
|
|
@ -361,7 +361,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
}
|
||||
|
||||
template<typename _Tp>
|
||||
constexpr _Tp
|
||||
constexpr int
|
||||
__bit_width(_Tp __x) noexcept
|
||||
{
|
||||
constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits;
|
||||
|
@ -448,9 +448,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
bit_floor(_Tp __x) noexcept
|
||||
{ return std::__bit_floor(__x); }
|
||||
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 3656. Inconsistent bit operations returning a count
|
||||
/// The smallest integer greater than the base-2 logarithm of `x`.
|
||||
template<typename _Tp>
|
||||
constexpr _If_is_unsigned_integer<_Tp>
|
||||
constexpr _If_is_unsigned_integer<_Tp, int>
|
||||
bit_width(_Tp __x) noexcept
|
||||
{ return std::__bit_width(__x); }
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// { dg-options "-std=gnu++20" }
|
||||
// { dg-do compile { target c++20 } }
|
||||
|
||||
#include <bit>
|
||||
|
||||
template<typename T> constexpr bool is_int = false;
|
||||
template<> constexpr bool is_int<int> = true;
|
||||
|
||||
// LWG 3656. Inconsistent bit operations returning a count
|
||||
// Rturn type of std::bit_width(T) changed from T to int.
|
||||
static_assert( is_int<decltype(std::bit_width(1u))> );
|
||||
static_assert( is_int<decltype(std::bit_width(1ul))> );
|
||||
static_assert( is_int<decltype(std::bit_width(1ull))> );
|
||||
static_assert( is_int<decltype(std::bit_width((unsigned short)1))> );
|
||||
static_assert( is_int<decltype(std::bit_width((unsigned char)1))> );
|
Loading…
Add table
Reference in a new issue