[libc] Added checks to src and dest types in bit_cast
authorMikhail R. Gadelha <mikhail@igalia.com>
Thu, 20 Apr 2023 23:30:23 +0000 (20:30 -0300)
committerMikhail R. Gadelha <mikhail@igalia.com>
Thu, 20 Apr 2023 23:31:29 +0000 (20:31 -0300)
commitba38640b9901d239e32e12c6569f7364d00af922
treecef3a4eb6b49711408294a15c01adcdcc04e5179
parent8704c3a31f6011ba43fc60bef7b3c9774b9e38d9
[libc] Added checks to src and dest types in bit_cast

This patch adds assertions to prevent the compilation when we try to
bit cast a type that is not trivially copyable when using
__builtin_bit_cast, or when we try to bit cast a type that is not
trivially copyable and trivially constructable when using memcpy.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D148739
libc/src/__support/CPP/bit.h
libc/src/__support/CPP/type_traits.h