libycxx
Contents

libycxx was written by AI agents whose models were trained on public code that likely includes these libraries, whose licences carry obligations; this analysis is the evidence of how close libycxx is to them. Why this exists.

Similarity analysis · findings

Findings and excerpts

Each finding is a judgment made in advance and committed in docs/similarity/findings.toml, with its rationale; the excerpts below are generated at build time from the pinned sources. Results that no finding, reviewed group or automatic rule covers are listed under Unreviewed.

Severity: none: no similarity beyond chance. expected: forced by the standard, an ABI, a platform or a registry, or by a published algorithm or reference implementation. notable: an arbitrary choice matching one library in a short or isolated place, where coincidence or diffuse influence is plausible. significant: an extended arbitrary match (structure together with internal names, comments or constants over tens of lines), suggesting derivation.

0significant
9notable
7expected
9unreviewed

notableF01 · Floating-point midpoint

local variable names and numeric thresholds · matches libstdc++, libc++ · libycxx: include/ycxx/core/numeric.hpp 339–366

The floating-point branch of std::midpoint has the same four-way case analysis, the same two threshold expressions and the same local-variable names as libstdc++'s. libc++ has the same algorithm and thresholds with different names. About twelve lines. The proposal that introduced midpoint (P0811R3) shows a different formula, so this form is not from the paper; it is, however, already shared by two established implementations.

Claims 2 computed result(s) this build.

libycxx include/ycxx/core/numeric.hpp 339–366
  338  
  339  // [numeric.ops.midpoint]
  340  template <class _Tp>
  341    requires __ycxx::__detail::__midpoint_arithmetic<_Tp>
  342  constexpr _Tp midpoint(_Tp a, _Tp b) noexcept {
  343    if constexpr (is_integral_v<_Tp>) {
  344      using _Up = make_unsigned_t<_Tp>;
  345      // The distance as an unsigned value, halved towards a.
  346      if (a > b)
  347        return static_cast<_Tp>(a - static_cast<_Tp>(static_cast<_Up>(static_cast<_Up>(a) - static_cast<_Up>(b)) / 2));
  348      return static_cast<_Tp>(a + static_cast<_Tp>(static_cast<_Up>(static_cast<_Up>(b) - static_cast<_Up>(a)) / 2));
  349    } else {
  350      // At most one inexact operation: halve the sum unless it could overflow; halve an operand
  351      // first only when it is too large, and the other one only when it is not tiny.
  352      constexpr _Tp __lo = numeric_limits<_Tp>::min() * 2;
  353      constexpr _Tp __hi = numeric_limits<_Tp>::max() / 2;
  354      const _Tp __abs_a = a < 0 ? -a : a;
  355      const _Tp __abs_b = b < 0 ? -b : b;
  356      if (__abs_a <= __hi && __abs_b <= __hi)
  357        return (a + b) / 2;
  358      if (__abs_a < __lo)
  359        return a + b / 2;
  360      if (__abs_b < __lo)
  361        return a / 2 + b;
  362      return a / 2 + b / 2;
  363    }
  364  }
  365  template <class _Tp>
  366    requires is_object_v<_Tp>
  367  constexpr _Tp* midpoint(_Tp* a, _Tp* b) noexcept {
libstdc++ include/std/numeric 243–256
  242  	}
  243        else // is_floating
  244  	{
  245  	  constexpr _Tp __lo = numeric_limits<_Tp>::min() * 2;
  246  	  constexpr _Tp __hi = numeric_limits<_Tp>::max() / 2;
  247  	  const _Tp __abs_a = __a < 0 ? -__a : __a;
  248  	  const _Tp __abs_b = __b < 0 ? -__b : __b;
  249  	  if (__abs_a <= __hi && __abs_b <= __hi) [[likely]]
  250  	    return (__a + __b) / 2; // always correctly rounded
  251  	  if (__abs_a < __lo) // not safe to halve __a
  252  	    return __a + __b/2;
  253  	  if (__abs_b < __lo) // not safe to halve __b
  254  	    return __a/2 + __b;
  255  	  return __a/2 + __b/2;	    // otherwise correctly rounded
  256  	}
  257      }
Excerpt from GCC 16.2.0 libstdc++ (gcc.gnu.org), GNU GPL v3 with the GCC Runtime Library Exception. Quoted for analysis.
libycxx include/ycxx/core/numeric.hpp 339–366
  338  
  339  // [numeric.ops.midpoint]
  340  template <class _Tp>
  341    requires __ycxx::__detail::__midpoint_arithmetic<_Tp>
  342  constexpr _Tp midpoint(_Tp a, _Tp b) noexcept {
  343    if constexpr (is_integral_v<_Tp>) {
  344      using _Up = make_unsigned_t<_Tp>;
  345      // The distance as an unsigned value, halved towards a.
  346      if (a > b)
  347        return static_cast<_Tp>(a - static_cast<_Tp>(static_cast<_Up>(static_cast<_Up>(a) - static_cast<_Up>(b)) / 2));
  348      return static_cast<_Tp>(a + static_cast<_Tp>(static_cast<_Up>(static_cast<_Up>(b) - static_cast<_Up>(a)) / 2));
  349    } else {
  350      // At most one inexact operation: halve the sum unless it could overflow; halve an operand
  351      // first only when it is too large, and the other one only when it is not tiny.
  352      constexpr _Tp __lo = numeric_limits<_Tp>::min() * 2;
  353      constexpr _Tp __hi = numeric_limits<_Tp>::max() / 2;
  354      const _Tp __abs_a = a < 0 ? -a : a;
  355      const _Tp __abs_b = b < 0 ? -b : b;
  356      if (__abs_a <= __hi && __abs_b <= __hi)
  357        return (a + b) / 2;
  358      if (__abs_a < __lo)
  359        return a + b / 2;
  360      if (__abs_b < __lo)
  361        return a / 2 + b;
  362      return a / 2 + b / 2;
  363    }
  364  }
  365  template <class _Tp>
  366    requires is_object_v<_Tp>
  367  constexpr _Tp* midpoint(_Tp* a, _Tp* b) noexcept {
libc++ libcxx/include/__numeric/midpoint.h 60–75
   59  
   60  template <class _Fp>
   61    requires(is_floating_point_v<_Fp>)
   62  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Fp midpoint(_Fp __a, _Fp __b) noexcept {
   63    constexpr _Fp __lo = numeric_limits<_Fp>::min() * 2;
   64    constexpr _Fp __hi = numeric_limits<_Fp>::max() / 2;
   65  
   66    // typical case: overflow is impossible
   67    if (std::__fp_abs(__a) <= __hi && std::__fp_abs(__b) <= __hi)
   68      return (__a + __b) / 2; // always correctly rounded
   69    if (std::__fp_abs(__a) < __lo)
   70      return __a + __b / 2; // not safe to halve a
   71    if (std::__fp_abs(__b) < __lo)
   72      return __a / 2 + __b; // not safe to halve b
   73  
   74    return __a / 2 + __b / 2; // otherwise correctly rounded
   75  }
   76  
Excerpt from LLVM 23.1.2 libc++/libc++abi (llvm.org), Apache License 2.0 with LLVM Exceptions. Quoted for analysis.

notableF02 · Sorting helper names from the HP/SGI STL

internal helper names · matches libstdc++ · libycxx: include/ycxx/core/algo_sort.hpp 349–361; include/ycxx/core/algo_sort.hpp 797–849; include/ycxx/core/algo_sort.hpp 917–993

Four sorting helpers in algo_sort.hpp (the unguarded insertion sort, the buffered stable partition, the buffered merge and the buffered stable sort) carry the same names as libstdc++'s corresponding helpers, and the buffered merge uses the same two local names for the cut lengths. The algorithms are written differently: the merge recurses on the smaller side, stable_sort is a top-down merge sort with its own cutoff, and sort is pdqsort. The names come from the 1994 HP/SGI STL and are reproduced in many books, so this is a naming echo rather than copied code.

Claims 8 computed result(s) this build.

libycxx include/ycxx/core/algo_sort.hpp 349–361
  348  template <class _Ops, class _Ip, class _Cp>
  349  constexpr void __unguarded_insertion_sort(_Ip first, _Ip last, _Cp less) {
  350    if (first == last)
  351      return;
  352    for (_Ip i = first + ::__ycxx::__detail::__diff_one<_Ip>; i != last; ++i) {
  353      _Ip __j = i;
  354      _Ip k = i - ::__ycxx::__detail::__diff_one<_Ip>;
  355      if (!less(*__j, *k))
  356        continue;
  357      std::iter_value_t<_Ip> __tmp(_Ops::iter_move(__j));
  358      do {
  359        *__j = _Ops::iter_move(k);
  360        __j = k;
  361        --k;
  362      } while (less(__tmp, *k));
libstdc++ include/bits/stl_algo.h 2361–2400
 2360      void
 2361      __merge_adaptive(_BidirectionalIterator __first,
 2362  		     _BidirectionalIterator __middle,
 2363  		     _BidirectionalIterator __last,
 2364  		     _Distance __len1, _Distance __len2,
 2365  		     _Pointer __buffer, _Compare __comp)
 2366      {
 2367        if (__len1 <= __len2)
 2368  	{
 2369  	  _Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer);
 2370  	  std::__move_merge_adaptive(__buffer, __buffer_end, __middle, __last,
 2371  				     __first, __comp);
 2372  	}
 2373        else
 2374  	{
 2375  	  _Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer);
 2376  	  std::__move_merge_adaptive_backward(__first, __middle, __buffer,
 2377  					      __buffer_end, __last, __comp);
 2378  	}
 2379      }
 2380  
 2381    template<typename _BidirectionalIterator, typename _Distance,
 2382  	   typename _Pointer, typename _Compare>
 2383      void
 2384      __merge_adaptive_resize(_BidirectionalIterator __first,
 2385  			    _BidirectionalIterator __middle,
 2386  			    _BidirectionalIterator __last,
 2387  			    _Distance __len1, _Distance __len2,
 2388  			    _Pointer __buffer, _Distance __buffer_size,
 2389  			    _Compare __comp)
 2390      {
 2391        if (__len1 <= __buffer_size || __len2 <= __buffer_size)
 2392  	std::__merge_adaptive(__first, __middle, __last,
 2393  			      __len1, __len2, __buffer, __comp);
 2394        else
 2395  	{
 2396  	  _BidirectionalIterator __first_cut = __first;
 2397  	  _BidirectionalIterator __second_cut = __middle;
 2398  	  _Distance __len11 = 0;
 2399  	  _Distance __len22 = 0;
      … (1 more lines)
Excerpt from GCC 16.2.0 libstdc++ (gcc.gnu.org), GNU GPL v3 with the GCC Runtime Library Exception. Quoted for analysis.

notableF03 · tuple stored as one base per element

implementation strategy and helper name · matches libc++ · libycxx: include/ycxx/core/tuple.hpp 1–80

tuple stores each element in its own base class, indexed by an index sequence and combined by multiple inheritance. libc++ uses this strategy, and the per-element base has the same name as libc++'s; libstdc++ and the MSVC STL use recursive inheritance instead. The strategy is widely published. libycxx holds the element as a [[no_unique_address]] member rather than through empty-base inheritance, and its allocator-construction plumbing differs.

Claims 2 computed result(s) this build.

libycxx include/ycxx/core/tuple.hpp 1–41
    1  // libycxx core: <tuple>, plus uses-allocator construction ([allocator.uses.construction]) which
    2  // is specified in terms of tuples.
    3  //
    4  // Layout: one base subobject per element (tuple_leaf<I, T>) holding the element as a
    5  // [[no_unique_address]] member, in declaration order, so empty elements take no space.
    6  #pragma once
    7  
    8  #include <ycxx/core/pair.hpp>
    9  #include <ycxx/core/ignore.hpp>
   10  #include <ycxx/core/memory_base.hpp>
   11  #include <ycxx/core/integer_sequence.hpp>
   12  
   13  namespace [[__gnu__::__visibility__(_YCXX_VISIBILITY)]] __ycxx { namespace __detail {
   14  
   15  template <class _Tp, class _Up>
   16  concept __different_from_ = !__is_same(std::remove_cvref_t<_Tp>, std::remove_cvref_t<_Up>);
   17  
   18  template <class _Tp>
   19  inline constexpr bool __is_tuple_specialization = false;
   20  template <class... _Ts>
   21  inline constexpr bool __is_tuple_specialization<std::tuple<_Ts...>> = true;
   22  
   23  struct __alloc_tag_t {};
   24  
   25  // Uses-allocator construction of one element in place ([allocator.uses.construction]).
   26  template <class _Tp, class _Alloc, class... _Args>
   27  constexpr _Tp __make_using_alloc(const _Alloc& a, _Args&&... __args);
   28  
   29  template <std::size_t _Ip, class _Tp>
   30  struct __tuple_leaf {
   31    [[no_unique_address]] _Tp value;
   32  
   33    constexpr __tuple_leaf() : value() {}
   34    template <class... _Args>
   35    constexpr explicit __tuple_leaf(std::in_place_t, _Args&&... __args) : value(static_cast<_Args&&>(__args)...) {}
   36    // Uses-allocator construction ([allocator.uses.construction]) performed directly into the
   37    // element: no intermediate prvalue, so non-movable elements work.
   38    template <class _Alloc, class... _Args>
   39      requires(!std::uses_allocator_v<std::remove_cv_t<_Tp>, _Alloc> && !__is_pair_v<std::remove_cv_t<_Tp>>)
   40    constexpr __tuple_leaf(__alloc_tag_t, const _Alloc&, _Args&&... __args) : value(static_cast<_Args&&>(__args)...) {}
      … (1 more lines)
libc++ libcxx/include/tuple 270–330
  269  #  include <__utility/integer_sequence.h>
  270  #  include <__utility/move.h>
  271  #  include <__utility/swap.h>
  272  #  include <version>
  273  
  274  // standard-mandated includes
  275  
  276  // [tuple.syn]
  277  #  include <compare>
  278  
  279  #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  280  #    pragma GCC system_header
  281  #  endif
  282  
  283  _LIBCPP_PUSH_MACROS
  284  #  include <__undef_macros>
  285  
  286  #  ifndef _LIBCPP_CXX03_LANG
  287  
  288  _LIBCPP_BEGIN_NAMESPACE_STD
  289  
  290  template <size_t _Ip, class _Tp, class _Up>
  291  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool __tuple_compare_equal(const _Tp& __x, const _Up& __y) {
  292    if constexpr (_Ip == 0)
  293      return true;
  294    else
  295      return std::__tuple_compare_equal<_Ip - 1>(__x, __y) && std::get<_Ip - 1>(__x) == std::get<_Ip - 1>(__y);
  296  }
  297  
  298  #    if _LIBCPP_STD_VER >= 20
  299  template <class _Ret, class _Tp, class _Up, size_t... _Is>
  300  _LIBCPP_HIDE_FROM_ABI constexpr _Ret __tuple_compare_three_way(const _Tp& __x, const _Up& __y, index_sequence<_Is...>) {
  301    _Ret __result = strong_ordering::equal;
  302    static_cast<void>(
  303        ((__result = std::__synth_three_way(std::get<_Is>(__x), std::get<_Is>(__y)), __result != 0) || ...));
  304    return __result;
  305  }
  306  #    endif // _LIBCPP_STD_VER >= 20
  307  
  308  #    if _LIBCPP_STD_VER >= 23
      … (22 more lines)
Excerpt from LLVM 23.1.2 libc++/libc++abi (llvm.org), Apache License 2.0 with LLVM Exceptions. Quoted for analysis.

notableF04 · shared_ptr control-block operation names

internal helper names · matches libc++ · libycxx: include/ycxx/core/shared_ptr.hpp 81–168

The control block's four reference-count operations have the same names as libc++'s. The counting convention, the atomic operations, the class layout and the disposal hook differ; the disposal hook and the control block's class name follow a third library's naming style.

Claims 8 computed result(s) this build.

libycxx include/ycxx/core/shared_ptr.hpp 81–121
   80    constexpr ~__sp_block() = default;
   81  
   82  public:
   83    __sp_block(const __sp_block&) = delete;
   84    __sp_block& operator=(const __sp_block&) = delete;
   85  
   86    // The stored deleter, if its type is the one `tag` identifies.
   87    constexpr virtual void* __deleter(const void* tag) noexcept {
   88      (void)tag;
   89      return nullptr;
   90    }
   91  
   92    // At run time the counts are atomic unless the process is single-threaded
   93    // (single_threaded.hpp). Increments are relaxed: a new reference is always made from an
   94    // existing one. A decrement releases and acquires (ref_release, single_threaded.hpp), so
   95    // everything the other owners did happens before the destruction.
   96    constexpr void __add_shared() noexcept {
   97      if consteval {
   98        ++__shared_;
   99      } else {
  100        if (::__ycxx::__detail::__single_threaded())
  101          ++__shared_;
  102        else
  103          __atomic_fetch_add(&__shared_, 1, __ATOMIC_RELAXED);
  104      }
  105    }
  106    // Takes a new shared reference unless the use count is already zero (weak_ptr::lock).
  107    constexpr bool __try_add_shared() noexcept {
  108      if consteval {
  109        if (__shared_ == 0)
  110          return false;
  111        ++__shared_;
  112        return true;
  113      } else {
  114        if (::__ycxx::__detail::__single_threaded()) {
  115          if (__shared_ == 0)
  116            return false;
  117          ++__shared_;
  118          return true;
  119        }
      … (2 more lines)
libc++ libcxx/include/__memory/shared_count.h 48–110
   47    __shared_count& operator=(const __shared_count&);
   48  
   49  protected:
   50    long __shared_owners_;
   51    virtual ~__shared_count();
   52  
   53  private:
   54    virtual void __on_zero_shared() _NOEXCEPT = 0;
   55  
   56  public:
   57    _LIBCPP_HIDE_FROM_ABI explicit __shared_count(long __refs = 0) _NOEXCEPT : __shared_owners_(__refs) {}
   58  
   59  #if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
   60    void __add_shared() noexcept;
   61    bool __release_shared() noexcept;
   62  #else
   63    _LIBCPP_HIDE_FROM_ABI void __add_shared() _NOEXCEPT { __libcpp_atomic_refcount_increment(__shared_owners_); }
   64    _LIBCPP_HIDE_FROM_ABI bool __release_shared() _NOEXCEPT {
   65      if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1) {
   66        __on_zero_shared();
   67        return true;
   68      }
   69      return false;
   70    }
   71  #endif
   72    _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT {
   73  #if _LIBCPP_HAS_THREADS
   74      return __atomic_load_n(&__shared_owners_, __ATOMIC_RELAXED) + 1;
   75  #else
   76      return __shared_owners_ + 1;
   77  #endif
   78    }
   79  };
   80  
   81  class _LIBCPP_EXPORTED_FROM_ABI __shared_weak_count : private __shared_count {
   82    long __shared_weak_owners_;
   83  
   84  public:
   85    _LIBCPP_HIDE_FROM_ABI explicit __shared_weak_count(long __refs = 0) _NOEXCEPT
   86        : __shared_count(__refs),
      … (24 more lines)
Excerpt from LLVM 23.1.2 libc++/libc++abi (llvm.org), Apache License 2.0 with LLVM Exceptions. Quoted for analysis.

notableF05 · Radix sort inside stable_sort for integers

design choice · matches libc++ · libycxx: include/ycxx/core/algo_sort.hpp 995–1095

stable_sort of integers under a standard comparison object switches to an LSD radix sort above a size threshold, a design only libc++ also has, and the helper and concept names match libc++'s. The threshold value, the byte-skipping logic and the code are different.

Claims 6 computed result(s) this build.

libycxx include/ycxx/core/algo_sort.hpp 995–1035
  994  
  995  // ---- stable_sort of integers ---------------------------------------------------------------
  996  // Integers ordered by one of the standard comparison objects: equivalent elements are equal
  997  // values, so the order among them cannot be observed and stable_sort may use any sort. Large
  998  // ranges get an LSD radix sort (a counting pass per byte, skipping bytes that all elements share)
  999  // through a buffer of n elements, smaller ones (or without the buffer) pdqsort; both stay within
 1000  // [stable.sort]/5's N log N comparisons (radix sort makes none).
 1001  
 1002  // 1: the comparator orders T ascending, -1: descending, 0: neither or unknown.
 1003  template <class _Cp, class _Tp>
 1004  inline constexpr int __std_order = 0;
 1005  template <class _Tp>
 1006  inline constexpr int __std_order<__pred_ref<std::less<void>>, _Tp> = 1;
 1007  template <class _Tp>
 1008  inline constexpr int __std_order<__pred_ref<std::less<_Tp>>, _Tp> = 1;
 1009  template <class _Tp>
 1010  inline constexpr int __std_order<__pred_ref<std::ranges::less>, _Tp> = 1;
 1011  template <class _Tp>
 1012  inline constexpr int __std_order<__pred_ref<std::greater<void>>, _Tp> = -1;
 1013  template <class _Tp>
 1014  inline constexpr int __std_order<__pred_ref<std::greater<_Tp>>, _Tp> = -1;
 1015  template <class _Tp>
 1016  inline constexpr int __std_order<__pred_ref<std::ranges::greater>, _Tp> = -1;
 1017  template <class _Tp>
 1018  inline constexpr int __std_order<__proj_comp<std::ranges::less, std::identity>, _Tp> = 1;
 1019  template <class _Tp>
 1020  inline constexpr int __std_order<__proj_comp<std::ranges::greater, std::identity>, _Tp> = -1;
 1021  
 1022  template <class _Ip, class _Cp>
 1023  concept __radix_sortable = std::contiguous_iterator<_Ip> && std::is_integral_v<std::iter_value_t<_Ip>> &&
 1024                             !std::is_same_v<std::iter_value_t<_Ip>, bool> &&
 1025                             std::is_same_v<std::iter_reference_t<_Ip>, std::iter_value_t<_Ip>&> &&
 1026                             __std_order<_Cp, std::iter_value_t<_Ip>> != 0;
 1027  
 1028  inline constexpr std::ptrdiff_t __radix_threshold = 512;
 1029  
 1030  // Sorts a[0, n) ascending (descending with _Desc), using b[0, n) as scratch.
 1031  template <bool _Desc, class _Tp>
 1032  void __radix_sort(_Tp* a, std::size_t n, _Tp* b) noexcept {
 1033    using _Up = std::make_unsigned_t<_Tp>;
      … (2 more lines)
libc++ libcxx/include/__algorithm/stable_sort.h 195–260
  194  
  195  template <class _Tp>
  196  struct __stable_sort_switch {
  197    static const unsigned value = 128 * is_trivially_copy_assignable<_Tp>::value;
  198  };
  199  
  200  #if _LIBCPP_STD_VER >= 17
  201  template <class _Tp>
  202  _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_min_bound() {
  203    static_assert(__is_ordered_integer_representable_v<_Tp>);
  204    if constexpr (sizeof(_Tp) == 1) {
  205      return 1 << 8;
  206    }
  207  
  208    return 1 << 10;
  209  }
  210  
  211  template <class _Tp>
  212  _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_max_bound() {
  213    static_assert(__is_ordered_integer_representable_v<_Tp>);
  214    if constexpr (sizeof(_Tp) >= 8) {
  215      return 1 << 15;
  216    }
  217  
  218    return 1 << 16;
  219  }
  220  #endif // _LIBCPP_STD_VER >= 17
  221  
  222  template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
  223  _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort(
  224      _RandomAccessIterator __first,
  225      _RandomAccessIterator __last,
  226      _Compare __comp,
  227      typename iterator_traits<_RandomAccessIterator>::difference_type __len,
  228      typename iterator_traits<_RandomAccessIterator>::value_type* __buff,
  229      ptrdiff_t __buff_size) {
  230    typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
  231    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
  232    switch (__len) {
  233    case 0:
      … (27 more lines)
Excerpt from LLVM 23.1.2 libc++/libc++abi (llvm.org), Apache License 2.0 with LLVM Exceptions. Quoted for analysis.

notableF06 · Small-string layout

data layout · matches libstdc++, MSVC STL · libycxx: include/ycxx/core/basic_string.hpp 79–96

basic_string's layout is the libstdc++ layout: the data pointer and the size first, then a union of the capacity and an inline buffer, with the long mode recognised by comparing the pointer with the buffer. The MSVC STL's inline capacity is the same size. The accessor for the long-mode test has libc++'s name, whose layout is different. A common, documented design.

Claims 3 computed result(s) this build.

libycxx include/ycxx/core/basic_string.hpp 79–96
   78    static constexpr bool __pocs = __alloc_traits::propagate_on_container_swap::value;
   79    static constexpr bool __always_equal = __alloc_traits::is_always_equal::value;
   80  
   81    // Inline buffer: 16 bytes' worth of characters (at least one, for the terminator).
   82    static constexpr size_t __buf_len = 16 / sizeof(__charT) > 1 ? 16 / sizeof(__charT) : 1;
   83    static constexpr size_type __sso_cap = __buf_len - 1;
   84  
   85    __charT* __ptr_;
   86    size_type __size_;
   87    union {
   88      size_type __cap_;
   89      __charT __buf_[__buf_len];
   90    };
   91    [[no_unique_address]] _Allocator __alloc_;
   92  
   93    // ---- representation helpers ----
   94    constexpr bool __is_long() const noexcept { return __ptr_ != __buf_; }
   95    constexpr size_type __cap() const noexcept { return __is_long() ? __cap_ : __sso_cap; }
   96  
   97    // Makes buf_ the active union member (ending cap_'s lifetime) and points ptr_ at it. During
libstdc++ include/bits/basic_string.h 210–225
  209  #endif
  210  
  211  	pointer _M_p; // The actual data.
  212        };
  213  
  214        _Alloc_hider	_M_dataplus;
  215        size_type		_M_string_length;
  216  
  217        enum { _S_local_capacity = 15 / sizeof(_CharT) };
  218  
  219        union
  220        {
  221  	_CharT           _M_local_buf[_S_local_capacity + 1];
  222  	size_type        _M_allocated_capacity;
  223        };
  224  
  225        _GLIBCXX20_CONSTEXPR
  226        void
Excerpt from GCC 16.2.0 libstdc++ (gcc.gnu.org), GNU GPL v3 with the GCC Runtime Library Exception. Quoted for analysis.

notableF07 · Red-black tree header

representation · matches libc++ · libycxx: include/ycxx/core/rb_tree.hpp 1–22

The tree's header node holds the root as its left child and the tree object caches the leftmost node, as libc++ does, with the same rationale given in the comment and the same accessor name. Unlike libc++, the header also tracks the rightmost node, as libstdc++ and the MSVC STL do. A hybrid of known designs.

libycxx include/ycxx/core/rb_tree.hpp 1–22
    1  // libycxx core: the red-black tree shared by map, multimap, set and multiset ([associative]).
    2  //
    3  // Representation: nodes {parent, left, right, red} with the element in a union member, so a
    4  // node can exist before and after its element (node handles). A header node closes the tree:
    5  // header.left is the root, header.right the rightmost node, header.parent null (the only node
    6  // whose parent is null, which is how iteration recognises it), root.parent is the header. The
    7  // header acts as a node greater than every element: the in-order successor of the rightmost
    8  // node is the header, which is end(). The leftmost node (begin()) is kept in the tree object.
    9  // While the tree holds no element, header.left is null, header.right the header itself, and the
   10  // leftmost pointer the header. Insertions never change end() ([associative.reqmts.general]/175),
   11  // also for a container that has never held an element. No constructor sets the header up: one
   12  // that may be constant-evaluated can neither store the object's own address nor allocate (a
   13  // constant-initialized container, a namespace-scope map, must stay constant). At run time the
   14  // header is head_, a member, which is end() from construction on; its links are set up by the
   15  // first insertion (hdr_ and first_ are null before; begin() is then end()). During constant
   16  // evaluation it is allocated with std::allocator instead (GCC 16 mis-evaluates pointers into an
   17  // object returned with NRVO, as for list), by the first member that needs it, const ones (end())
   18  // included: hdr_ and first_ are mutable, so no iterator exists before the header does. (So the
   19  // container cannot be a constexpr variable: its destructor reads hdr_. STATUS, known
   20  // limitations.) Moves and swaps relink the root to the other header; nodes are never copied by
   21  // moves.
   22  //
   23  // Elements are constructed and destroyed through the allocator rebound to the node type.
libc++ libcxx/include/__tree 40–110
   39  #include <__type_traits/remove_const.h>
   40  #include <__type_traits/remove_cvref.h>
   41  #include <__utility/forward.h>
   42  #include <__utility/lazy_synth_three_way_comparator.h>
   43  #include <__utility/move.h>
   44  #include <__utility/pair.h>
   45  #include <__utility/swap.h>
   46  #include <__utility/try_key_extraction.h>
   47  #include <limits>
   48  
   49  #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
   50  #  pragma GCC system_header
   51  #endif
   52  
   53  _LIBCPP_PUSH_MACROS
   54  #include <__undef_macros>
   55  
   56  _LIBCPP_DIAGNOSTIC_PUSH
   57  // GCC complains about the backslashes at the end, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121528
   58  _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wcomment")
   59  // __tree is a red-black-tree implementation used for the associative containers (i.e. (multi)map/set). It stores
   60  // - (1) a pointer to the node with the smallest (i.e. leftmost) element, namely __begin_node_
   61  // - (2) the number of nodes in the tree, namely __size_
   62  // - (3) a pointer to the root of the tree, namely __end_node_
   63  //
   64  // Storing (1) and (2) is required to allow for constant time lookups. A tree looks like this in memory:
   65  //
   66  //      __end_node_
   67  //           |
   68  //          root
   69  //         /    \
   70  //       l1       r1
   71  //      /  \     /  \
   72  //    ...  ... ...  ...
   73  //
   74  // All nodes except __end_node_ have a __left_ and __right_ pointer as well as a __parent_ pointer.
   75  // __end_node_ only contains a __left_ pointer, which points to the root of the tree.
   76  // This layout allows for iteration through the tree without a need for special handling of the end node. See
   77  // __tree_next_iter and __tree_prev_iter for more details.
   78  _LIBCPP_DIAGNOSTIC_POP
      … (32 more lines)
Excerpt from LLVM 23.1.2 libc++/libc++abi (llvm.org), Apache License 2.0 with LLVM Exceptions. Quoted for analysis.

notableF08 · Single internal names shared with libstdc++

internal helper names · matches libstdc++ · libycxx: include/ycxx/core/shared_ptr.hpp 531–545; include/ycxx/core/vector.hpp 229–259; include/ycxx/core/basic_string.hpp 46–46; include/ycxx/core/atomic_smart_ptr.hpp 43–63; include/ycxx/core/generator.hpp 58–78; include/ycxx/core/format_base.hpp 895–1035; include/ycxx/core/compare_alg.hpp 83–87; include/ycxx/core/ranges_join.hpp 50–72

Several single internal names in different headers match libstdc++'s exactly: the shared_from_this hook (shared_ptr.hpp), the reallocating insertion (vector.hpp), the string-view alias (basic_string.hpp), the base of the atomic smart pointers (atomic_smart_ptr.hpp), the generator's copy awaiter (generator.hpp), the width and precision kind fields of the format specification (format_base.hpp), three concepts of the comparison customization points (compare_alg.hpp) and two concat_view helper predicates (ranges_join.hpp). Each is a short descriptive name; the code around them is structured differently (for example, the atomic smart pointers use a striped lock table and the concat predicates use pack indexing).

Claims 19 computed result(s) this build.

libycxx include/ycxx/core/shared_ptr.hpp 531–545
  530    template <class _Yp>
  531    constexpr void __enable_shared_from_this_with(_Yp* p) noexcept {
  532      if constexpr (requires { __ycxx::__detail::__sp_esft_base(p); }) {
  533        auto* base = __ycxx::__detail::__sp_esft_base(p);
  534        if (p != nullptr && base->__weak_this_.expired())
  535          base->__weak_this_ = shared_ptr<remove_cv_t<_Yp>>(*this, const_cast<remove_cv_t<_Yp>*>(p));
  536      }
  537    }
  538  
  539    template <class _Yp, class _Dp, class _Ap>
  540    constexpr void __adopt(_Yp* p, _Dp& d, const _Ap& a) {
  541      __ctrl_ = __ycxx::__detail::__sp_make_ptr_block(p, d, a);
  542      __ptr_ = p;
  543      if constexpr (!is_array_v<_Tp>)
  544        __enable_shared_from_this_with(p);
  545    }
  546  
libstdc++ include/bits/shared_ptr_base.h 1555–1572
 1554  	explicit
 1555  	__shared_ptr(_Yp* __p)
 1556  	: _M_ptr(__p), _M_refcount(__p, typename is_array<_Tp>::type())
 1557  	{
 1558  	  static_assert( !is_void<_Yp>::value, "incomplete type" );
 1559  	  static_assert( sizeof(_Yp) > 0, "incomplete type" );
 1560  	  _M_enable_shared_from_this_with(__p);
 1561  	}
 1562  
 1563        template<typename _Yp, typename _Deleter, typename = _SafeConv<_Yp>>
 1564  	__shared_ptr(_Yp* __p, _Deleter __d)
 1565  	: _M_ptr(__p), _M_refcount(__p, std::move(__d))
 1566  	{
 1567  	  static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
 1568  	      "deleter expression d(p) is well-formed");
 1569  	  _M_enable_shared_from_this_with(__p);
 1570  	}
 1571  
 1572        template<typename _Yp, typename _Deleter, typename _Alloc,
 1573  	       typename = _SafeConv<_Yp>>
Excerpt from GCC 16.2.0 libstdc++ (gcc.gnu.org), GNU GPL v3 with the GCC Runtime Library Exception. Quoted for analysis.

notableF09 · io_errc message text

error-message string · matches MSVC STL · libycxx: src/hosted/ios.cpp 9–19

The message text for the one io_errc value is identical to the MSVC STL's. It is the category name followed by the enumerator's name, so it may well be an independent composition.

Claims 1 computed result(s) this build.

libycxx src/hosted/ios.cpp 9–19
    8  
    9  class iostream_error_category final : public std::error_category {
   10  public:
   11    constexpr iostream_error_category() noexcept {}
   12    const char* name() const noexcept override { return "iostream"; }
   13    std::string message(int __ev) const override {
   14      if (__ev == static_cast<int>(std::io_errc::stream))
   15        return "iostream stream error";
   16      return "unknown iostream error";
   17    }
   18  };
   19  
   20  template <class _Tp>
MSVC STL stl/inc/system_error 560–572
  559      constexpr _Iostream_error_category2() noexcept : error_category(_Iostream_addr) {}
  560  
  561      _NODISCARD const char* name() const noexcept override {
  562          return "iostream";
  563      }
  564  
  565      _NODISCARD string message(int _Errcode) const override {
  566          if (_Errcode == static_cast<int>(io_errc::stream)) {
  567              static constexpr char _Iostream_error[] = "iostream stream error";
  568              constexpr size_t _Iostream_error_length = sizeof(_Iostream_error) - 1; // TRANSITION, DevCom-906503
  569              return string{_Iostream_error, _Iostream_error_length};
  570          } else {
  571              return _Syserror_map(_Errcode);
  572          }
  573      }
Excerpt from microsoft/STL (github.com/microsoft/STL), Apache License 2.0 with LLVM Exceptions. Quoted for analysis.

expectedE01 · chrono::round follows the published date library

published reference implementation · matches libstdc++ · libycxx: include/ycxx/core/chrono_base.hpp 307–319

chrono::round uses the same four local names and steps as libstdc++; both follow H. Hinnant's public date library, the reference implementation behind the chrono proposals, which uses those names.

Claims 3 computed result(s) this build.

libycxx include/ycxx/core/chrono_base.hpp 307–319
  306    requires __ycxx::__detail::__is_duration<_ToDuration> && (!treat_as_floating_point_v<typename _ToDuration::rep>)
  307  constexpr _ToDuration round(const duration<_Rep, _Period>& d) {
  308    _ToDuration __t0 = chrono::floor<_ToDuration>(d);
  309    _ToDuration __t1 = __t0 + _ToDuration{1};
  310    auto __diff0 = d - __t0;
  311    auto __diff1 = __t1 - d;
  312    if (__diff0 == __diff1)
  313      return (__t0.count() & 1) ? __t1 : __t0;
  314    return __diff0 < __diff1 ? __t0 : __t1;
  315  }
  316  
  317  // [time.duration.alg]
  318  template <class _Rep, class _Period>
  319    requires numeric_limits<_Rep>::is_signed
  320  constexpr duration<_Rep, _Period> abs(duration<_Rep, _Period> d) {
libstdc++ include/bits/chrono.h 436–452
  435  	       __not_<treat_as_floating_point<typename _ToDur::rep>>>::value,
  436  	_ToDur>
  437        round(const duration<_Rep, _Period>& __d)
  438        {
  439  	_ToDur __t0 = chrono::floor<_ToDur>(__d);
  440  	_ToDur __t1 = __t0 + _ToDur{1};
  441  	auto __diff0 = __d - __t0;
  442  	auto __diff1 = __t1 - __d;
  443  	if (__diff0 == __diff1)
  444  	  {
  445  	    if (__t0.count() & 1)
  446  	      return __t1;
  447  	    return __t0;
  448  	  }
  449  	else if (__diff0 < __diff1)
  450  	  return __t0;
  451  	return __t1;
  452        }
  453  
Excerpt from GCC 16.2.0 libstdc++ (gcc.gnu.org), GNU GPL v3 with the GCC Runtime Library Exception. Quoted for analysis.

expectedE02 · pdqsort's published constants

published algorithm constants · matches libc++, libstdc++, MSVC STL · libycxx: include/ycxx/core/algo_sort.hpp 325–729

std::sort is pattern-defeating quicksort with branchless block partitioning. Its four tuning constants are those of the published pdqsort reference implementation (O. R. L. Peters, 2021), which libc++ also adopted. The insertion-sort cutoff of the other sorting paths is the classic value used across STL implementations since the HP STL.

Claims 7 computed result(s) this build.

libycxx include/ycxx/core/algo_sort.hpp 325–365
  324  }
  325  
  326  inline constexpr int __insertion_sort_threshold = 16;
  327  
  328  // ---- sort: pattern-defeating quicksort --------------------------------------------------------
  329  // O. R. L. Peters, "Pattern-defeating Quicksort" (arXiv:2106.05123), with the branchless block
  330  // partitioning of S. Edelkamp and A. Weiss, "BlockQuicksort: Avoiding Branch Mispredictions in
  331  // Quicksort" (ESA 2016, JEA 2019) for contiguous ranges of scalars:
  332  //   - median of three, or Tukey's ninther above 128 elements, as the pivot;
  333  //   - a partition that swapped nothing (sorted or nearly sorted input) is followed by an
  334  //     insertion sort that gives up after 8 moves, so sorted runs cost O(n);
  335  //   - when the element left of the range equals the pivot (it is a previous pivot, not greater
  336  //     than anything in the range), the elements equal to it are split off at once, so many
  337  //     duplicates cost O(n log k) for k distinct values;
  338  //   - a partition leaving fewer than 1/8 on one side swaps a few elements to break patterns,
  339  //     and after log2(n) such partitions the range is heapsorted: O(n log n) comparisons in the
  340  //     worst case ([sort]/5).
  341  inline constexpr std::ptrdiff_t __pdq_insertion_threshold = 24;
  342  inline constexpr std::ptrdiff_t __pdq_ninther_threshold = 128;
  343  inline constexpr std::ptrdiff_t __pdq_partial_insertion_limit = 8;
  344  inline constexpr int __pdq_block = 64;
  345  
  346  // Insertion sort of [first, last) whose element before first is not greater than any of them
  347  // (a previous pivot), so the inner loop needs no bound check.
  348  template <class _Ops, class _Ip, class _Cp>
  349  constexpr void __unguarded_insertion_sort(_Ip first, _Ip last, _Cp less) {
  350    if (first == last)
  351      return;
  352    for (_Ip i = first + ::__ycxx::__detail::__diff_one<_Ip>; i != last; ++i) {
  353      _Ip __j = i;
  354      _Ip k = i - ::__ycxx::__detail::__diff_one<_Ip>;
  355      if (!less(*__j, *k))
  356        continue;
  357      std::iter_value_t<_Ip> __tmp(_Ops::iter_move(__j));
  358      do {
  359        *__j = _Ops::iter_move(k);
  360        __j = k;
  361        --k;
  362      } while (less(__tmp, *k));
  363      *__j = std::move(__tmp);
      … (2 more lines)
libc++ libcxx/include/__algorithm/sort.h 720–760
  719                   _Compare __comp,
  720                   typename iterator_traits<_RandomAccessIterator>::difference_type __depth,
  721                   bool __leftmost = true) {
  722    using _Ops = _IterOps<_AlgPolicy>;
  723    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
  724    using _Comp_ref = __comp_ref_type<_Compare>;
  725    // Upper bound for using insertion sort for sorting.
  726    _LIBCPP_CONSTEXPR difference_type __limit = 24;
  727    // Lower bound for using Tuckey's ninther technique for median computation.
  728    _LIBCPP_CONSTEXPR difference_type __ninther_threshold = 128;
  729    while (true) {
  730      difference_type __len = __last - __first;
  731      switch (__len) {
  732      case 0:
  733      case 1:
  734        return;
  735      case 2:
  736        if (__comp(*--__last, *__first))
  737          _Ops::iter_swap(__first, __last);
  738        return;
  739      case 3:
  740        std::__sort3<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
  741        return;
  742      case 4:
  743        std::__sort4<_AlgPolicy, _Compare>(
  744            __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp);
  745        return;
  746      case 5:
  747        std::__sort5<_AlgPolicy, _Compare>(
  748            __first,
  749            __first + difference_type(1),
  750            __first + difference_type(2),
  751            __first + difference_type(3),
  752            --__last,
  753            __comp);
  754        return;
  755      }
  756      // Use insertion sort if the length of the range is below the specified limit.
  757      if (__len < __limit) {
  758        if (__leftmost) {
      … (2 more lines)
Excerpt from LLVM 23.1.2 libc++/libc++abi (llvm.org), Apache License 2.0 with LLVM Exceptions. Quoted for analysis.

expectedE03 · IANA registry data and the standard's encoding ids

registry and standard data · matches all three · libycxx: include/ycxx/core/text_encoding_table.hpp 1–1139; include/ycxx/core/text_encoding.hpp 1–499

The text_encoding alias table is generated from the IANA Character Sets registry by tools/gen_text_encoding.py, in registry order, and the encoding ids are enumerated by the standard. The largest token matches of the whole analysis are this data, and so are most string literals shared with libstdc++.

Claims 736 computed result(s) this build.

libycxx include/ycxx/core/text_encoding_table.hpp 1–41
    1  // Generated by tools/gen_text_encoding.py from tools/data/iana-character-sets.csv (the IANA
    2  // Character Sets registry, last updated 2026-10-02). Do not edit.
    3  #pragma once
    4  
    5  #include <ycxx/core/cstdint.hpp>
    6  
    7  namespace [[__gnu__::__visibility__(_YCXX_VISIBILITY)]] __ycxx { namespace __detail {
    8  
    9  struct __te_name {
   10    std::int_least32_t mib;
   11    const char* name;
   12  };
   13  
   14  inline constexpr __te_name __te_names[882] = {
   15      {3, "US-ASCII"}, {3, "iso-ir-6"}, {3, "ANSI_X3.4-1968"}, {3, "ANSI_X3.4-1986"}, {3, "ISO_646.irv:1991"}, {3, "ISO646-US"}, {3, "us"}, {3, "IBM367"
   16      {4, "ISO_8859-1:1987"}, {4, "iso-ir-100"}, {4, "ISO_8859-1"}, {4, "ISO-8859-1"}, {4, "latin1"}, {4, "l1"}, {4, "IBM819"}, {4, "CP819"}, {4, "csISO
   17      {5, "ISO_8859-2:1987"}, {5, "iso-ir-101"}, {5, "ISO_8859-2"}, {5, "ISO-8859-2"}, {5, "latin2"}, {5, "l2"}, {5, "csISOLatin2"},
   18      {6, "ISO_8859-3:1988"}, {6, "iso-ir-109"}, {6, "ISO_8859-3"}, {6, "ISO-8859-3"}, {6, "latin3"}, {6, "l3"}, {6, "csISOLatin3"},
   19      {7, "ISO_8859-4:1988"}, {7, "iso-ir-110"}, {7, "ISO_8859-4"}, {7, "ISO-8859-4"}, {7, "latin4"}, {7, "l4"}, {7, "csISOLatin4"},
   20      {8, "ISO_8859-5:1988"}, {8, "iso-ir-144"}, {8, "ISO_8859-5"}, {8, "ISO-8859-5"}, {8, "cyrillic"}, {8, "csISOLatinCyrillic"},
   21      {9, "ISO_8859-6:1987"}, {9, "iso-ir-127"}, {9, "ISO_8859-6"}, {9, "ISO-8859-6"}, {9, "ECMA-114"}, {9, "ASMO-708"}, {9, "arabic"}, {9, "csISOLatinA
   22      {10, "ISO_8859-7:1987"}, {10, "iso-ir-126"}, {10, "ISO_8859-7"}, {10, "ISO-8859-7"}, {10, "ELOT_928"}, {10, "ECMA-118"}, {10, "greek"}, {10, "gree
   23      {11, "ISO_8859-8:1988"}, {11, "iso-ir-138"}, {11, "ISO_8859-8"}, {11, "ISO-8859-8"}, {11, "hebrew"}, {11, "csISOLatinHebrew"},
   24      {12, "ISO_8859-9:1989"}, {12, "iso-ir-148"}, {12, "ISO_8859-9"}, {12, "ISO-8859-9"}, {12, "latin5"}, {12, "l5"}, {12, "csISOLatin5"},
   25      {13, "ISO-8859-10"}, {13, "iso-ir-157"}, {13, "l6"}, {13, "ISO_8859-10:1992"}, {13, "csISOLatin6"}, {13, "latin6"},
   26      {14, "ISO_6937-2-add"}, {14, "iso-ir-142"}, {14, "csISOTextComm"},
   27      {15, "JIS_X0201"}, {15, "X0201"}, {15, "csHalfWidthKatakana"},
   28      {16, "JIS_Encoding"}, {16, "csJISEncoding"},
   29      {17, "Shift_JIS"}, {17, "MS_Kanji"}, {17, "csShiftJIS"},
   30      {18, "Extended_UNIX_Code_Packed_Format_for_Japanese"}, {18, "csEUCPkdFmtJapanese"}, {18, "EUC-JP"},
   31      {19, "Extended_UNIX_Code_Fixed_Width_for_Japanese"}, {19, "csEUCFixWidJapanese"},
   32      {20, "BS_4730"}, {20, "iso-ir-4"}, {20, "ISO646-GB"}, {20, "gb"}, {20, "uk"}, {20, "csISO4UnitedKingdom"},
   33      {21, "SEN_850200_C"}, {21, "iso-ir-11"}, {21, "ISO646-SE2"}, {21, "se2"}, {21, "csISO11SwedishForNames"},
   34      {22, "IT"}, {22, "iso-ir-15"}, {22, "ISO646-IT"}, {22, "csISO15Italian"},
   35      {23, "ES"}, {23, "iso-ir-17"}, {23, "ISO646-ES"}, {23, "csISO17Spanish"},
   36      {24, "DIN_66003"}, {24, "iso-ir-21"}, {24, "de"}, {24, "ISO646-DE"}, {24, "csISO21German"},
   37      {25, "NS_4551-1"}, {25, "iso-ir-60"}, {25, "ISO646-NO"}, {25, "no"}, {25, "csISO60DanishNorwegian"}, {25, "csISO60Norwegian1"},
   38      {26, "NF_Z_62-010"}, {26, "iso-ir-69"}, {26, "ISO646-FR"}, {26, "fr"}, {26, "csISO69French"},
   39      {27, "ISO-10646-UTF-1"}, {27, "csISO10646UTF1"},
   40      {28, "ISO_646.basic:1983"}, {28, "ref"}, {28, "csISO646basic1983"},
      … (1 more lines)
libstdc++ include/bits/text_encoding-data.h 30–60
   29   */
   30  
   31  #ifndef _GLIBCXX_GET_ENCODING_DATA
   32  # error "This is not a public header, do not include it directly"
   33  #endif
   34  
   35    {    3, "US-ASCII" },
   36    {    3, "iso-ir-6" },
   37    {    3, "ANSI_X3.4-1968" },
   38    {    3, "ANSI_X3.4-1986" },
   39    {    3, "ISO_646.irv:1991" },
   40    {    3, "ISO646-US" },
   41    {    3, "us" },
   42    {    3, "IBM367" },
   43    {    3, "cp367" },
   44    {    3, "csASCII" },
   45    {    3, "ASCII" }, // libstdc++ extension
   46    {    4, "ISO_8859-1:1987" },
   47    {    4, "iso-ir-100" },
   48    {    4, "ISO_8859-1" },
   49    {    4, "ISO-8859-1" },
   50    {    4, "latin1" },
   51    {    4, "l1" },
   52    {    4, "IBM819" },
   53    {    4, "CP819" },
   54    {    4, "csISOLatin1" },
   55    {    5, "ISO_8859-2:1987" },
   56    {    5, "iso-ir-101" },
   57    {    5, "ISO_8859-2" },
   58    {    5, "ISO-8859-2" },
   59    {    5, "latin2" },
   60    {    5, "l2" },
   61    {    5, "csISOLatin2" },
Excerpt from GCC 16.2.0 libstdc++ (gcc.gnu.org), GNU GPL v3 with the GCC Runtime Library Exception. Quoted for analysis.

expectedE04 · Itanium demangler output conventions

ABI and de facto output format · matches all three · libycxx: src/hosted/demangle.cpp 1–2011; src/hosted/demangle.hpp 1–28; src/hosted/cxa_demangle.cpp 1–49

The demangler shares output strings and grammar comments with the GNU demangler (and a few with libc++abi's): the Itanium C++ ABI's mangling grammar and the demangled-output conventions any compatible demangler reproduces. The demangler's code shows no structural similarity (its k-gram similarities are near zero).

Claims 25 computed result(s) this build.

libycxx src/hosted/demangle.cpp 1–41
    1  // libycxx hosted runtime: an Itanium C++ ABI demangler (Itanium C++ ABI 5.1, "External Names
    2  // (a.k.a. Mangling)"), written from that specification.
    3  //
    4  // The parser builds a small tree of nodes (names, types, function encodings) and prints it in
    5  // the style of the toolchains' c++filt. Types print in two parts (left and right of the
    6  // declarator), so that "pointer to function" comes out as "void (*)(int)". The substitution
    7  // table and the template-parameter table follow 5.1.9-5.1.10. Expressions in template
    8  // arguments are supported for the common forms (literals, template and function parameters,
    9  // operators, sizeof/alignof, casts, calls, member access); anything else makes demangle()
   10  // fail, and the caller shows the mangled name.
   11  #include "demangle.hpp"
   12  
   13  #include <cstddef>
   14  #include <cstring>
   15  #include <limits>
   16  #include <memory>
   17  #include <new>
   18  #include <string_view>
   19  #include <utility>
   20  #include <ycxx/core/error.hpp>
   21  
   22  namespace {
   23  
   24  using std::string_view;
   25  using std::size_t;
   26  
   27  // Printing a pack expansion measures the pattern, then renders each element in turn.
   28  struct pack_state {
   29    int index = -1; // -1: all elements; -2: measuring the pack
   30    int size = -1;
   31  };
   32  
   33  struct active_param;
   34  
   35  // A failed allocation aborts this invocation, including any intermediate renders.
   36  struct scratch_state {
   37    explicit scratch_state(bool propagate) noexcept : propagate_allocations(propagate) {}
   38    bool failed = false;
   39    pack_state pack;
   40    bool fail() noexcept {
      … (1 more lines)
libstdc++ libiberty/cp-demangle.c 1550–1560
 1549    if (substable && !subst && !d_add_substitution (di, dc))
 1550      return NULL;
 1551    return dc;
 1552  }
 1553  
 1554  /* <nested-name> ::= N [<CV-qualifiers>] [<ref-qualifier>] <prefix> <unqualified-name> E
 1555                   ::= N [<CV-qualifiers>] [<ref-qualifier>] <template-prefix> <template-args> E
 1556                   ::= N H <prefix> <unqualified-name> E
 1557                   ::= N H <template-prefix> <template-args> E
 1558  */
 1559  
 1560  static struct demangle_component *
 1561  d_nested_name (struct d_info *di)
Excerpt from GCC 16.2.0 libstdc++ (gcc.gnu.org), libiberty's demangler: GPL v2 or later with a linking exception, as stated in the file. Quoted for analysis.

expectedE05 · Itanium C++ ABI type_info declarations

ABI-specified declarations · matches all three, libcxxrt · libycxx: src/abi/rtti.hpp 1–387; src/abi/rtti.cpp 1–363

The type_info subclasses, their data members and their flag masks (names and values) are specified by the Itanium C++ ABI and match all three ABI runtimes.

Claims 6 computed result(s) this build.

libycxx src/abi/rtti.hpp 1–41
    1  // libycxx ABI runtime: the RTTI classes of the Itanium C++ ABI (§2.9.4) and helpers shared by
    2  // handler matching and __dynamic_cast. Not installed.
    3  //
    4  // The compilers emit type_info objects whose vtable pointers name the vtables of these classes
    5  // (_ZTVN10__cxxabiv1...E); the vtables, and the type_info objects of the fundamental types, are
    6  // emitted by rtti_classes.cpp, which defines every class's key function (its destructor). The data
    7  // members are laid out exactly as §2.9.4 specifies; the member functions are ours alone.
    8  #pragma once
    9  
   10  #include <cstddef>
   11  #include <typeinfo>
   12  
   13  namespace [[__gnu__::__visibility__("hidden")]] __cxxabiv1 {
   14  
   15  class __fundamental_type_info : public std::type_info {
   16  public:
   17    explicit __fundamental_type_info(const char* n) noexcept : std::type_info(n) {}
   18    ~__fundamental_type_info() override;
   19  };
   20  
   21  class __array_type_info : public std::type_info {
   22  public:
   23    explicit __array_type_info(const char* n) noexcept : std::type_info(n) {}
   24    ~__array_type_info() override;
   25  };
   26  
   27  class __function_type_info : public std::type_info {
   28  public:
   29    explicit __function_type_info(const char* n) noexcept : std::type_info(n) {}
   30    ~__function_type_info() override;
   31  };
   32  
   33  class __enum_type_info : public std::type_info {
   34  public:
   35    explicit __enum_type_info(const char* n) noexcept : std::type_info(n) {}
   36    ~__enum_type_info() override;
   37  };
   38  
   39  // A class with no bases (and the base of the other two class representations). Also used,
   40  // as a local object, for incomplete classes named by pointer RTTI.
      … (1 more lines)
libc++ libcxxabi/src/private_typeinfo.h 170–230
  169          __virtual_mask = 0x1,
  170          __public_mask  = 0x2, // base is public
  171          __offset_shift = 8
  172      };
  173  
  174      void search_above_dst(__dynamic_cast_info*, const void*, const void*, int, bool) const;
  175      void search_below_dst(__dynamic_cast_info*, const void*, int, bool) const;
  176      void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;
  177  };
  178  
  179  // Has one or more base classes
  180  class _LIBCXXABI_TYPE_VIS __vmi_class_type_info : public __class_type_info {
  181  public:
  182    unsigned int __flags;
  183    unsigned int __base_count;
  184    __base_class_type_info __base_info[1];
  185  
  186    enum __flags_masks {
  187      __non_diamond_repeat_mask = 0x1, // has two or more distinct base class
  188                                       //    objects of the same type
  189      __diamond_shaped_mask = 0x2      // has base class object with two or
  190                                       //    more derived objects
  191    };
  192  
  193    _LIBCXXABI_HIDDEN virtual ~__vmi_class_type_info();
  194  
  195    _LIBCXXABI_HIDDEN virtual void search_above_dst(__dynamic_cast_info *,
  196                                                    const void *, const void *,
  197                                                    int, bool) const;
  198    _LIBCXXABI_HIDDEN virtual void
  199    search_below_dst(__dynamic_cast_info *, const void *, int, bool) const;
  200    _LIBCXXABI_HIDDEN virtual void
  201    has_unambiguous_public_base(__dynamic_cast_info *, void *, int) const;
  202  };
  203  
  204  class _LIBCXXABI_TYPE_VIS __pbase_type_info : public __shim_type_info {
  205  public:
  206    unsigned int __flags;
  207    _LIBCXXABI_DISABLE_POINTER_FIELD_PROTECTION const __shim_type_info* __pointee;
  208  
      … (22 more lines)
Excerpt from LLVM 23.1.2 libc++/libc++abi (llvm.org), Apache License 2.0 with LLVM Exceptions. Quoted for analysis.

expectedE06 · Standard-specified engine parameters

standard-specified constants · matches all three · libycxx: include/ycxx/core/random_engines.hpp 1–1022

The random-number engines' parameters, seeds and constants (Mersenne twister, philox, the default seeds) are specified by [rand.predef] and [rand.eng].

Claims 15 computed result(s) this build.

libycxx include/ycxx/core/random_engines.hpp 1–41
    1  // libycxx core: the random number engines and engine adaptors of <random> ([rand.eng],
    2  // [rand.adapt], [rand.predef]) and seed_seq ([rand.util.seedseq]).
    3  //
    4  // Every engine keeps its state so that the textual representation and equality follow the
    5  // draft's sequence X directly: the lagged engines (mersenne_twister_engine,
    6  // subtract_with_carry_engine) keep X in a ring buffer whose oldest element is at `__pos_`, and
    7  // compare and print it in logical order. All arithmetic is done in unsigned long long and
    8  // reduced modulo 2^w (or m), so narrow UIntTypes never meet integral promotion.
    9  #pragma once
   10  
   11  #include <initializer_list>
   12  #include <ycxx/core/array.hpp>
   13  #include <ycxx/core/iterator_core.hpp>
   14  #include <ycxx/core/move.hpp>
   15  #include <ycxx/core/random_base.hpp>
   16  #include <ycxx/core/vector.hpp>
   17  
   18  namespace [[__gnu__::__visibility__(_YCXX_VISIBILITY)]] std { inline namespace __y1 {
   19  
   20  // ---- [rand.util.seedseq] ------------------------------------------------------------------------
   21  class seed_seq {
   22  public:
   23    using result_type = uint_least32_t;
   24  
   25    seed_seq() noexcept {}
   26    template <class _Tp>
   27      requires is_integral_v<_Tp>
   28    seed_seq(initializer_list<_Tp> il) : seed_seq(il.begin(), il.end()) {}
   29    template <class _InputIterator>
   30    seed_seq(_InputIterator begin, _InputIterator end) {
   31      static_assert(is_integral_v<typename iterator_traits<_InputIterator>::value_type>,
   32                    "seed_seq: the iterator's value_type must be an integer type");
   33      for (_InputIterator s = begin; s != end; ++s)
   34        __v_.push_back(static_cast<result_type>(static_cast<uint32_t>(*s)));
   35    }
   36  
   37    template <class _RandomAccessIterator>
   38    void generate(_RandomAccessIterator begin, _RandomAccessIterator end) {
   39      using _Vp = typename iterator_traits<_RandomAccessIterator>::value_type;
   40      static_assert(is_unsigned_v<_Vp> && !is_same_v<_Vp, bool> && numeric_limits<_Vp>::digits >= 32,
      … (1 more lines)
libstdc++ include/bits/random.h 2300–2330
 2299     *
 2300     * Reference:
 2301     * M. Matsumoto and T. Nishimura, Mersenne Twister: A 623-Dimensionally
 2302     * Equidistributed Uniform Pseudo-Random Number Generator, ACM Transactions
 2303     * on Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
 2304     */
 2305    typedef mersenne_twister_engine<
 2306      uint_fast32_t,
 2307      32, 624, 397, 31,
 2308      0x9908b0dfUL, 11,
 2309      0xffffffffUL, 7,
 2310      0x9d2c5680UL, 15,
 2311      0xefc60000UL, 18, 1812433253UL> mt19937;
 2312  
 2313    /**
 2314     * An alternative Mersenne Twister.
 2315     */
 2316    typedef mersenne_twister_engine<
 2317      uint_fast64_t,
 2318      64, 312, 156, 31,
 2319      0xb5026f5aa96619e9ULL, 29,
 2320      0x5555555555555555ULL, 17,
 2321      0x71d67fffeda60000ULL, 37,
 2322      0xfff7eee000000000ULL, 43,
 2323      6364136223846793005ULL> mt19937_64;
 2324  
 2325    typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24>
 2326      ranlux24_base;
 2327  
 2328    typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>
 2329      ranlux48_base;
 2330  
 2331    typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
Excerpt from GCC 16.2.0 libstdc++ (gcc.gnu.org), GNU GPL v3 with the GCC Runtime Library Exception. Quoted for analysis.

expectedE07 · POSIX collating-element names

POSIX-specified data · matches libc++ · libycxx: src/hosted/regex.cpp 32–72

The regex collating-element table lists the names of the POSIX portable character set (Base Definitions 6.1); its shape (pairs of a name and a character) follows from that.

Claims 9 computed result(s) this build.

libycxx src/hosted/regex.cpp 32–72
   31  
   32  // The collating-symbol names of the POSIX portable character set (Base Definitions, 6.1 and
   33  // the control characters of 6.3) with the characters they stand for.
   34  constexpr name_entry collate_names[] = {
   35      {"NUL", 0x00}, {"SOH", 0x01}, {"STX", 0x02}, {"ETX", 0x03}, {"EOT", 0x04}, {"ENQ", 0x05}, {"ACK", 0x06},
   36      {"BEL", 0x07}, {"alert", 0x07}, {"BS", 0x08}, {"backspace", 0x08}, {"HT", 0x09}, {"tab", 0x09},
   37      {"LF", 0x0A}, {"newline", 0x0A}, {"VT", 0x0B}, {"vertical-tab", 0x0B}, {"FF", 0x0C}, {"form-feed", 0x0C},
   38      {"CR", 0x0D}, {"carriage-return", 0x0D}, {"SO", 0x0E}, {"SI", 0x0F}, {"DLE", 0x10}, {"DC1", 0x11},
   39      {"DC2", 0x12}, {"DC3", 0x13}, {"DC4", 0x14}, {"NAK", 0x15}, {"SYN", 0x16}, {"ETB", 0x17}, {"CAN", 0x18},
   40      {"EM", 0x19}, {"SUB", 0x1A}, {"ESC", 0x1B}, {"IS4", 0x1C}, {"FS", 0x1C}, {"IS3", 0x1D}, {"GS", 0x1D},
   41      {"IS2", 0x1E}, {"RS", 0x1E}, {"IS1", 0x1F}, {"US", 0x1F}, {"space", 0x20}, {"exclamation-mark", 0x21},
   42      {"quotation-mark", 0x22}, {"number-sign", 0x23}, {"dollar-sign", 0x24}, {"percent-sign", 0x25},
   43      {"ampersand", 0x26}, {"apostrophe", 0x27}, {"left-parenthesis", 0x28}, {"right-parenthesis", 0x29},
   44      {"asterisk", 0x2A}, {"plus-sign", 0x2B}, {"comma", 0x2C}, {"hyphen", 0x2D}, {"hyphen-minus", 0x2D},
   45      {"period", 0x2E}, {"full-stop", 0x2E}, {"slash", 0x2F}, {"solidus", 0x2F}, {"zero", 0x30}, {"one", 0x31},
   46      {"two", 0x32}, {"three", 0x33}, {"four", 0x34}, {"five", 0x35}, {"six", 0x36}, {"seven", 0x37},
   47      {"eight", 0x38}, {"nine", 0x39}, {"colon", 0x3A}, {"semicolon", 0x3B}, {"less-than-sign", 0x3C},
   48      {"equals-sign", 0x3D}, {"greater-than-sign", 0x3E}, {"question-mark", 0x3F}, {"commercial-at", 0x40},
   49      {"left-square-bracket", 0x5B}, {"backslash", 0x5C}, {"reverse-solidus", 0x5C},
   50      {"right-square-bracket", 0x5D}, {"circumflex", 0x5E}, {"circumflex-accent", 0x5E}, {"underscore", 0x5F},
   51      {"low-line", 0x5F}, {"grave-accent", 0x60}, {"left-brace", 0x7B}, {"left-curly-bracket", 0x7B},
   52      {"vertical-line", 0x7C}, {"right-brace", 0x7D}, {"right-curly-bracket", 0x7D}, {"tilde", 0x7E},
   53      {"DEL", 0x7F},
   54  };
   55  
   56  } // namespace
   57  
   58  namespace [[__gnu__::__visibility__(_YCXX_VISIBILITY)]] __ycxx { namespace __detail {
   59  
   60  unsigned __regex_class_by_name(const char* name, std::size_t n, bool icase) noexcept {
   61    for (const name_entry& e : class_names) {
   62      if (!__same(name, e.name, n))
   63        continue;
   64      unsigned m = static_cast<unsigned>(e.value);
   65      // [re.traits] footnote 217: without regard to case, [[:lower:]] is the same as [[:alpha:]].
   66      if (icase && (m == std::ctype_base::lower || m == std::ctype_base::upper))
   67        m = std::ctype_base::alpha;
   68      return m;
   69    }
   70    return 0;
      … (2 more lines)
libc++ libcxx/src/regex.cpp 70–110
   69    const char* elem_;
   70    char char_;
   71  };
   72  
   73  #if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
   74  // EBCDIC IBM-1047
   75  // Sorted via the EBCDIC collating sequence
   76  const collationnames collatenames[] = {
   77      {"a", 0x81},
   78      {"alert", 0x2f},
   79      {"ampersand", 0x50},
   80      {"apostrophe", 0x7d},
   81      {"asterisk", 0x5c},
   82      {"b", 0x82},
   83      {"backslash", 0xe0},
   84      {"backspace", 0x16},
   85      {"c", 0x83},
   86      {"carriage-return", 0xd},
   87      {"circumflex", 0x5f},
   88      {"circumflex-accent", 0x5f},
   89      {"colon", 0x7a},
   90      {"comma", 0x6b},
   91      {"commercial-at", 0x7c},
   92      {"d", 0x84},
   93      {"dollar-sign", 0x5b},
   94      {"e", 0x85},
   95      {"eight", 0xf8},
   96      {"equals-sign", 0x7e},
   97      {"exclamation-mark", 0x5a},
   98      {"f", 0x86},
   99      {"five", 0xf5},
  100      {"form-feed", 0xc},
  101      {"four", 0xf4},
  102      {"full-stop", 0x4b},
  103      {"g", 0x87},
  104      {"grave-accent", 0x79},
  105      {"greater-than-sign", 0x6e},
  106      {"h", 0x88},
  107      {"hyphen", 0x60},
  108      {"hyphen-minus", 0x60},
      … (2 more lines)
Excerpt from LLVM 23.1.2 libc++/libc++abi (llvm.org), Apache License 2.0 with LLVM Exceptions. Quoted for analysis.

Unreviewed (9)

unreviewedabi_runtime · libc++ · 80 tokens (kgram-lexical)

shared internal names: none · lexical ratio 1.0 · standard vocabulary 0.0 · key 7e3ba286ba3c113a

libycxx src/abi/rtti_classes.cpp 24–33
   23  // references _ZTIDF16_ for typeid(_Float16), so rtti_float16.cpp supplies it.
   24  __fundamental_type_info::~__fundamental_type_info() {}
   25  __array_type_info::~__array_type_info() {}
   26  __function_type_info::~__function_type_info() {}
   27  __enum_type_info::~__enum_type_info() {}
   28  __class_type_info::~__class_type_info() {}
   29  __si_class_type_info::~__si_class_type_info() {}
   30  __vmi_class_type_info::~__vmi_class_type_info() {}
   31  __pbase_type_info::~__pbase_type_info() {}
   32  __pointer_type_info::~__pointer_type_info() {}
   33  __pointer_to_member_type_info::~__pointer_to_member_type_info() {}
   34  
libc++ libcxxabi/src/private_typeinfo.cpp 343–399
  342  //   3. pointers to all of the const fundamental types
  343  __fundamental_type_info::~__fundamental_type_info()
  344  {
  345  }
  346  
  347  // __array_type_info
  348  
  349  __array_type_info::~__array_type_info()
  350  {
  351  }
  352  
  353  // __function_type_info
  354  
  355  __function_type_info::~__function_type_info()
  356  {
  357  }
  358  
  359  // __enum_type_info
  360  
  361  __enum_type_info::~__enum_type_info()
  362  {
  363  }
  364  
  365  // __class_type_info
  366  
  367  __class_type_info::~__class_type_info()
  368  {
  369  }
  370  
  371  // __si_class_type_info
  372  
  373  __si_class_type_info::~__si_class_type_info()
  374  {
  375  }
  376  
  377  // __vmi_class_type_info
  378  
  379  __vmi_class_type_info::~__vmi_class_type_info()
  380  {
  381  }
      … (18 more lines)
Excerpt from LLVM 23.1.2 libc++/libc++abi (llvm.org), Apache License 2.0 with LLVM Exceptions. Quoted for analysis.
CategoryItemlibycxxOtherKey
ident_exact__abi_versioninclude/ycxx/config.hpp:455libstdc++ include/bits/atomic_wait.h:1751c68e25dd871b17e
ident_exact__d_lastinclude/ycxx/core/vector.hpp:360libstdc++ include/pstl/algorithm_impl.h:1483cfd5c9ef442b4adc
ident_exact__dst_typesrc/abi/dynamic_cast.cpp:134libstdc++ libsupc++/cxxabi.h:457afb7723ff8585ff1
ident_exact__src_typesrc/abi/dynamic_cast.cpp:134libstdc++ libsupc++/cxxabi.h:4785c337508606f7037
ident_exact__begin_nodeinclude/ycxx/core/rb_tree.hpp:493libc++ libcxx/include/forward_list:2844c23fcc3301b3760
ident_coreabi_versioninclude/ycxx/config.hpp:455libstdc++ include/bits/atomic_wait.h:1751242d499ed3655ae
ident_coredst_typesrc/abi/dynamic_cast.cpp:134libstdc++ libsupc++/cxxabi.h:457e49b9cde7b5d3445
ident_coresrc_typesrc/abi/dynamic_cast.cpp:134libstdc++ libsupc++/cxxabi.h:478efca4fee7865e43a

Reviewed groups and automatic rules

Group or ruleSeverityWhatThis build
G-matchesexpectedReviewed matches of standard-specified code
Long matches the automatic rules could not dismiss because they contain a generic internal name (an '_impl' helper, an 'is_' test, a throw helper, an allocator-traits alias) or have a lower share of standard vocabulary. Reviewed: each reproduces code the standard specifies (comparison and constraint formulas, deleted copy operations, container member lists, formatter defaults, node-iterator boilerplate) or a compiler builtin.
18
G-namesexpectedDescriptive and conventional internal names
Internal names libycxx shares with exactly one library that are descriptive compounds of the standard's names or of terms of art (an 'is_' test, an '_impl' or '_fn' helper, a '_t' alias, a '_base' class), names of compiler attributes and platform symbols, and naming-convention coincidences. Reviewed as a list; the distinctive names are findings F02 to F08.
474
G-stringsexpectedPlatform names, environment variables and generic phrases
Strings shared with one library that are file system paths and file names of the operating system and the time zone database, environment variable names, locale category names, POSIX collating names, demangler fragments outside the demangler's files, and short generic phrases naming the standard's own classes and errors.
27
G-numbersexpectedSpecified, published and mathematical constants
Numbers and tables shared with one library: standard-specified parameters, published-algorithm constants (Marsaglia and Tsang's gamma method, Hinnant's civil-date arithmetic), IEEE floating-point limits, ECMAScript line terminators, calendar data, powers of small integers and coincidences of small values.
20
G-typosnoneNot misspellings
The misspelling heuristic's hits for libycxx are correctly spelled words, British spellings and identifiers mentioned in comments: no shared misspelling.
8
standard-shapedexpectedautomatic rule
The match shares no internal (reserved, non-standard) name with the other library, and at least 70% of libycxx's identifiers in it are the standard's own vocabulary: code whose shape the standard specifies (synopses, "Equivalent to" bodies, exposition-only classes).
2182
shape-onlyexpectedautomatic rule
The match shares no internal name and the spelling differs (lexical ratio below 0.5): only the token structure is alike.
1