So I took a look at False 1 4 V512 A call of the 'memcpy' function will lead to overflow of the buffer '& x'. code pstypes.h 131 False
I can either fix it the easy way and just expand the memcpy into three assignments or fix it properly and convert vertex[/tt] to using vec3ds. I started to do the conversion, but when I realized that this is going to touch most of the graphics code I figured I should ask for an opinion? Do it right or fix it quick? The layout of this struct is abused all over the code in similar fashion os the one the PVS-Studio is complaining about.
I just took a look at this myself. In general, when there is a choice between "do it right" and "do it quick", I say "do it right". However, in this case, the "quick" fix isn't wrong. It really depends on how widespread the struct abuse is. (Keep in mind that the union of a1d and xyz isn't abuse; it's two ways of looking at the same data.)
The specific abuse that PVS-Studio complains about is only in one place because the the code in question is conveniently a function. On the other hand, the class of abuse, where the three floats are cast to/from a vec3d is pretty common, especially in the 3d graphics code.
On the other hand, zooming out one level, I don't even thing the = and == functions are supposed to be there. Notice that the struct includes padding for 4-byte alignment. But the struct isn't going to be the size the code thinks it is because it also needs to store information about the member functions. I would say, on the contrary, that the = and == functions should be removed (and from vec3d as well).
To be honest, its a question of code style and paradigm. We both know that

and the SCP have been fast and loose about style and paradigm. Do we adopt the more C++ object style that my patch was going for or do we revert this back a more procedural C style.
I agree about the operators. The == operator can be moved to be a global function, as an operator or otherwise, which will remove it from the vtable. And now that I have thought about it, I don't see the point the assignment operator, it is disingenuous at best, and should be removed.
As for the member functions of the vec3d, set_screen_vert doesn't appear to be used at all. The assignment operator is another one of the places that the trio of floats get abused and memcpyed to a vec3d. The equality operator for vec3d, like vertex can be made into a global function to remove it from the vtable and unlike the == operator for vertex it does not mislead and is used heavily.
Regarding the padding. I think it is odd that they would be manually padding the structure (you ask the compiler to do it for you instead), and sadly they didn't leave a note as to why it needs to be padded. Either way, the vtable will not break the 4 byte alignment because the vtable entries are always pointers (4 or 8 bytes which doesn't hurt you there). But you are correct, the struct is has more information tagged on it that is not being accounted for, which is why this heavy use of memset/memcpy gets us into trouble, see the question about style and paradigm above. On the other hand, empirically (VS2010 and the sizeof operator) the vertex struct is 44 bytes and the vect3d struct is 12 bytes, exactly as expected, so...
Let me therefore suggest this as the new version of the struct:
typedef struct vertex {
union {
struct {
float x, y, z; // world space position
} world;
float world_a1d[3];
}
union {
struct {
float sx, sy, sw; // screen space position (sw == 1/z)
} screen;
float screen_a1d[3];
}
float u, v; // texture position
ubyte r, g, b, a; // color. Use b for darkening;
ubyte spec_r, spec_g, spec_b, spec_a; //specular highlights -Bobboau
ubyte codes; // what sides of view pyramid this point is on/off. 0 = Inside view pyramid.
ubyte flags; // Projection flags. Indicates whether it is projected or not or if projection overflowed.
ubyte pad[2]; // pad structure to be 4 byte aligned.
} vertex;
I think it is a bit daft to just ignore vect3d in the vertex structure. They seem to go hand in hand through the code. It seems (based on the = operators and some of the code I have seen), vertex is the graphics code equivalent of vec3d.