Replaced reinterpret cast with memcpy in GenericFeaturesPNextNode.

This commit is contained in:
Vibi Manx 2021-09-11 00:42:38 -04:00 committed by Charles Giessen
parent f5f9b54f38
commit ad394dce69
2 changed files with 6 additions and 3 deletions

View File

@ -36,8 +36,9 @@ namespace vkb {
namespace detail { namespace detail {
GenericFeaturesPNextNode::GenericFeaturesPNextNode() GenericFeaturesPNextNode::GenericFeaturesPNextNode() {
: fields() {} // zero initializes the array of fields memset(this, UINT8_MAX, sizeof(GenericFeaturesPNextNode));
}
bool GenericFeaturesPNextNode::match( bool GenericFeaturesPNextNode::match(
GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported) noexcept { GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported) noexcept {

View File

@ -18,6 +18,7 @@
#include <cassert> #include <cassert>
#include <cstdio> #include <cstdio>
#include <cstring>
#include <vector> #include <vector>
#include <system_error> #include <system_error>
@ -122,7 +123,8 @@ struct GenericFeaturesPNextNode {
GenericFeaturesPNextNode(); GenericFeaturesPNextNode();
template <typename T> GenericFeaturesPNextNode(T const& features) noexcept { template <typename T> GenericFeaturesPNextNode(T const& features) noexcept {
*reinterpret_cast<T*>(this) = features; memset(this, UINT8_MAX, sizeof(GenericFeaturesPNextNode));
memcpy(this, &features, sizeof(T));
} }
static bool match(GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported) noexcept; static bool match(GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported) noexcept;