Describe the enhancement requested
Currently, the functions in util/ubsan.h require a type that is trivially copyable. However, before performing its intended operation, it calls the default constructor of the type, as shown in the code below:
|
inline std::enable_if_t<std::is_trivially_copyable_v<T>, T> SafeLoadAs( |
|
const uint8_t* unaligned) { |
|
std::remove_const_t<T> ret; |
|
std::memcpy(&ret, unaligned, sizeof(T)); |
|
return ret; |
|
} |
It is possible, however, for a type to be trivially copyable without having a default constructor, for example:
struct A {
A(int a) : a(a) {}
int a;
};
Component(s)
C++