Given the following C++ code:
struct vertex_type {
float x, y, z;
//vertex_type() {}
//vertex_type(float x, float y, float z) : x(x), y(y), z(z) {}
If you have custom constructor, the compiler should call it for all vector it create. If you don't write your own, it default to a generated constructor. But as no type are complex, it just don't need to call it. And the array is store as a constant table in the binary.
Try inlining your default constructor and let it empty. Of course, it may only work wit h optimization enabled
This is a long-standing missing optimization in GCC. It should be able to generate the same code for both cases, but it can't.
Without the constructors, your vertex_type
is a POD structure, which GCC can initialize static/global instances of at compile time. With the constructors, the best it can do is generate code to initialize the global at program startup.