public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-4293] libstdc++: Change return type of std::bit_width to int (LWG 3656)
@ 2022-11-25 0:23 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-11-25 0:23 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:4581328022615c2cb732cfb404151c4b059d26e3
commit r13-4293-g4581328022615c2cb732cfb404151c4b059d26e3
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Nov 24 21:36:07 2022 +0000
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.
Diff:
---
libstdc++-v3/doc/html/manual/bugs.html | 4 ++++
libstdc++-v3/doc/xml/manual/intro.xml | 7 +++++++
libstdc++-v3/include/std/bit | 6 ++++--
.../testsuite/26_numerics/bit/bit.pow.two/lwg3656.cc | 15 +++++++++++++++
4 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/doc/html/manual/bugs.html b/libstdc++-v3/doc/html/manual/bugs.html
index 58600cd6ede..c4a2c26ea39 100644
--- a/libstdc++-v3/doc/html/manual/bugs.html
+++ b/libstdc++-v3/doc/html/manual/bugs.html
@@ -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>
\ No newline at end of file
diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml
index dee01c82159..aee96e37c61 100644
--- a/libstdc++-v3/doc/xml/manual/intro.xml
+++ b/libstdc++-v3/doc/xml/manual/intro.xml
@@ -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>
diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit
index 2fd80187210..3e072ef2113 100644
--- a/libstdc++-v3/include/std/bit
+++ b/libstdc++-v3/include/std/bit
@@ -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); }
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/lwg3656.cc b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/lwg3656.cc
new file mode 100644
index 00000000000..4752c3b1d33
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/lwg3656.cc
@@ -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))> );
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-25 0:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 0:23 [gcc r13-4293] libstdc++: Change return type of std::bit_width to int (LWG 3656) Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).