New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VertexLoaderTest: Fix memset assignment warning #9595
VertexLoaderTest: Fix memset assignment warning #9595
Conversation
Initialize and assign members of TVtxDesc and VAT structs directly instead of using memset. Fixes -Wclass-memaccess warning from gcc on Debian.
0e96e1b
to
1cc035e
Compare
|
As an alternative to specifying default values in CPMemory.h, this seems to be valid (but is much more awkward looking than when used for single structs): TVtxDesc vtx_desc{.low{.Hex = 0}, .high{.Hex = 0}};
VAT vat{.g0{.Hex = 0}, .g1{.Hex = 0}, .g2{.Hex = 0}}; |
| m_vtx_desc.low.Hex = 0; | ||
| m_vtx_desc.high.Hex = 0; | ||
|
|
||
| m_vtx_attr.g0.Hex = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be shortened to:
| m_vtx_attr.g0.Hex = 0; | |
| m_vtx_attr = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work because the copy assignment operator for BitField has been deleted.
I tried creating a copy assignment operator for TVtxDesc and VAT to copy the respective member .Hex fields, but kept getting errors (I believe from the BitFieldArrays in TVtxDesc .low and .high) about the operation not being sane.
| @@ -50,8 +48,12 @@ class VertexLoaderTest : public testing::Test | |||
| memset(input_memory, 0, sizeof(input_memory)); | |||
| memset(output_memory, 0xFF, sizeof(input_memory)); | |||
|
|
|||
| memset(&m_vtx_desc, 0, sizeof(m_vtx_desc)); | |||
| memset(&m_vtx_attr, 0, sizeof(m_vtx_attr)); | |||
| m_vtx_desc.low.Hex = 0; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be shortened to:
| m_vtx_desc.low.Hex = 0; | |
| m_vtx_desc = {}; |
e3140d0
to
1cc035e
Compare
Testing a fix for Debian unit test warning -Wclass-memaccess.