I like static_cast

This commit is contained in:
rusefi 2019-06-17 10:22:43 -04:00
parent 2b43c3f4f9
commit 9b1d57adf6
1 changed files with 6 additions and 0 deletions

View File

@ -70,7 +70,13 @@ TEST(misc, cppVirtualStructMemoryLayout) {
memcpy(&destimationInt, &c, 4);
ASSERT_NE(540, destimationInt);
// static_cast is smart to skip the vtable, we like static_cast
TestParent *parent = static_cast<TestParent*>(&c);
ASSERT_EQ(0, (int)&c.field0 - (int)parent);
ASSERT_EQ(MAGIC_VTABLE_SIZE, (int)&c.field0 - (int)&c);
}
TEST(misc, cppPlainExtraFieldsStructMemoryLayout) {