[Bug libstdc++/122907] [15/16 Regression] std::copy incorrectly uses memcpy when copying from signed or unsigned char buffer to bool buffer

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Dec 1 11:00:56 GMT 2025


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122907

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
  // For heterogeneous types, allow memcpy between equal-sized integers.
  // N.B. we cannot do the same for equal-sized enums, they're not assignable.
  // We cannot do it for pointers, because derived-to-base can adjust offset.
  template<typename _Tp, typename _Up>
    struct __memcpyable<_Tp*, _Up*>
    {
      enum {
        __value = __memcpyable_integer<_Tp>::__width != 0
                    && ((int)__memcpyable_integer<_Tp>::__width
                          == (int)__memcpyable_integer<_Up>::__width)
      };
    };
Guess it needs to be 0 even if one but not both of _Tp and _Up is bool/const
bool.


More information about the Gcc-bugs mailing list