Skip to content

Commit 4586d69

Browse files
committed
Rebase
1 parent f31da61 commit 4586d69

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

libcxx/include/bitset

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ protected:
260260
return __to_ulong();
261261
}
262262

263-
# ifndef _LIBCPP_CXX03_LANG
264263
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {
265264
// Check for overflow if _Size does not fit in unsigned long long
266265
if _LIBCPP_CONSTEXPR (_Size > sizeof(unsigned long long) * CHAR_BIT) {
@@ -284,7 +283,6 @@ protected:
284283
return __r;
285284
}
286285
}
287-
# endif
288286

289287
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return !__scan_bits(__bit_not()); }
290288
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT {
@@ -335,15 +333,6 @@ private:
335333
# ifdef _LIBCPP_CXX03_LANG
336334
void __init(unsigned long long __v, false_type) _NOEXCEPT;
337335
_LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT;
338-
339-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong(false_type) const;
340-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong(true_type) const;
341-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong(true_type, false_type) const;
342-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong(true_type, true_type) const;
343-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong(false_type) const;
344-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong(true_type) const;
345-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong(true_type, false_type) const;
346-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong(true_type, true_type) const;
347336
# else
348337
template <size_t... _Indices>
349338
_LIBCPP_HIDE_FROM_ABI constexpr __bitset(unsigned long long __v, std::__tuple_indices<_Indices...>) _NOEXCEPT
@@ -391,7 +380,7 @@ inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long
391380
# endif
392381
{
393382
# ifdef _LIBCPP_CXX03_LANG
394-
__init(__v, _BoolConstant<sizeof(unsigned long long) == sizeof(__storage_type)>());
383+
__init(__v, _BoolConstant<sizeof(unsigned long long) <= sizeof(__storage_type)>());
395384
# endif
396385
}
397386

@@ -501,7 +490,6 @@ protected:
501490
return static_cast<unsigned long>(__first_);
502491
}
503492

504-
# ifndef _LIBCPP_CXX03_LANG
505493
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {
506494
// If _Size exceeds the size of unsigned long long, check for overflow
507495
if _LIBCPP_CONSTEXPR (_Size > sizeof(unsigned long long) * CHAR_BIT) {
@@ -513,7 +501,6 @@ protected:
513501
// If _Size fits or no overflow, directly cast to unsigned long long
514502
return static_cast<unsigned long long>(__first_);
515503
}
516-
# endif
517504

518505
template <bool _Sparse, class _CharT, class _Traits, class _Allocator>
519506
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
@@ -540,8 +527,9 @@ inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0)
540527

541528
template <size_t _Size>
542529
inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
543-
// TODO: This is a workaround for a GCC bug causing stage1 CI (generic-gcc, gcc-14, g++-14)
544-
// failure due to __bits_per_word lookup failure if not referenced here.
530+
// TODO: This is a workaround for a gdb test failure (gdb_pretty_printer_test.sh.cpp) in
531+
// stage1 CI (generic-gcc, gcc-14, g++-14), due to the __bits_per_word name lookup failure
532+
// if not referenced in the constructor initializer list.
545533
// See: https://github.com/llvm/llvm-project/actions/runs/15071518915/job/42368867929?pr=121348#logs
546534
: __first_(_Size == __bits_per_word ? static_cast<__storage_type>(__v) : static_cast<__storage_type>(__v)) {}
547535

@@ -630,9 +618,7 @@ protected:
630618
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT {}
631619

632620
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { return 0UL; }
633-
# ifndef _LIBCPP_CXX03_LANG
634621
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { return 0ULL; }
635-
# endif
636622

637623
template <bool _Sparse, class _CharT, class _Traits, class _Allocator>
638624
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
@@ -660,8 +646,6 @@ class bitset : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) *
660646
public:
661647
static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1;
662648
typedef __bitset<__n_words, _Size> __base;
663-
664-
public:
665649
typedef typename __base::reference reference;
666650
typedef typename __base::__const_reference __const_reference;
667651

@@ -744,11 +728,9 @@ public:
744728
return __base::__make_ref(__p);
745729
}
746730
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { return __base::to_ulong(); }
747-
# ifndef _LIBCPP_CXX03_LANG
748731
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {
749732
return __base::to_ullong();
750733
}
751-
# endif
752734
template <class _CharT, class _Traits, class _Allocator>
753735
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
754736
to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const;

libcxx/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03, no-exceptions
9+
// UNSUPPORTED: no-exceptions
1010

1111
// unsigned long long to_ullong() const; // constexpr since C++23
1212

@@ -61,7 +61,7 @@ TEST_CONSTEXPR_CXX23 bool test() {
6161

6262
if (!TEST_IS_CONSTANT_EVALUATED) {
6363
// bitset has true bits beyond the size of unsigned long long
64-
std::bitset<std::numeric_limits<unsigned long long>::digits + 1> q{0};
64+
std::bitset<std::numeric_limits<unsigned long long>::digits + 1> q(0);
6565
q.flip();
6666
try {
6767
q.to_ullong(); // throws

0 commit comments

Comments
 (0)