struct Line
{
Bounds bounds_;
Vector origin_;
uint32_t begin_;
uint32_t end_;
dist ascent_;
dist descent_;
};
which is used as follows:
Line line = {};
while (!parser.done()) {
line = Line(); // zero-initialize
...
}
Bounds
and Vector
are non-POD classes, dist
is a typedef for int64_t
.
However, an optimized 32-bit release build of VC++11, seems to leave at least parts of line
uninitialized inside the while loop. Why? According to Do the parentheses after the type name make a difference with new?, it should have zero-initialized it, right?
I log the values of the struct members to a file:
- after
Line line = {};
: non-POD types are default-initialized, the others are 0. - after
line = Line();
: POD types still default initialized, others contain random values.