diff options
author | Jacques Lucke <jacques@blender.org> | 2021-09-21 18:50:53 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-09-21 18:51:15 +0300 |
commit | 3c1e75a2301c352dac72b1742cdd8efa2b335d6e (patch) | |
tree | 92110d3bcd3367a7ff0da2bb299fd4831d168f0a /source/blender/functions/FN_cpp_type_make.hh | |
parent | 2df7d1ebce862a7c7471f7a6ba3d7d14d392b3a5 (diff) |
Functions: make asserts more correct
It is valid to e.g. copy construct an integer in the same place,
because it is a trivial type. It does not work for types like std::string.
This fixes a crash reported in D12584 where it would copy a buffer
into itself. We should probably also avoid doing this copy alltogether
but that can be done separately.
Diffstat (limited to 'source/blender/functions/FN_cpp_type_make.hh')
-rw-r--r-- | source/blender/functions/FN_cpp_type_make.hh | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/source/blender/functions/FN_cpp_type_make.hh b/source/blender/functions/FN_cpp_type_make.hh index 088f6b469f4..74dbcabf81a 100644 --- a/source/blender/functions/FN_cpp_type_make.hh +++ b/source/blender/functions/FN_cpp_type_make.hh @@ -195,6 +195,7 @@ CPPType::CPPType(CPPTypeParam<T, Flags> /* unused */, StringRef debug_name) debug_name_ = debug_name; size_ = (int64_t)sizeof(T); alignment_ = (int64_t)alignof(T); + is_trivial_ = std::is_trivial_v<T>; is_trivially_destructible_ = std::is_trivially_destructible_v<T>; if constexpr (std::is_default_constructible_v<T>) { default_construct_ = default_construct_cb<T>; |