Commit 1459d852 by Jari Komppa Committed by Jari Komppa

Add check for vtable in memset template

This change makes sure the memset template is not used with classes that contain virtual members. Bug: b/152253831 Change-Id: I07d4777f33a9bd55c8f99d8b50a80c13df5d5805 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/49648 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarJari Komppa <jari@siru.fi>
parent e6c94972
......@@ -38,6 +38,7 @@ struct Memset
Memset(T *object, int val)
{
static_assert(std::is_base_of<Memset<T>, T>::value, "Memset<T> must only clear the memory of a type of which it is a base class");
static_assert(!std::is_polymorphic<T>::value, "Memset<T> must not be used with classes that have virtual functions");
::memset(object, 0, sizeof(T));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment