I have following struct whose member is another struct:
struct SA { ...};struct S { SA a; ...};
And in the code I need to reset struct frequently, with:
// data memberS m_s;// member functionvoid clear() { m_s.a = {}; m_s.b = {}; ...}
I'm using gcc version 7.3.1. With debug build, this works fine, with release build, it fails with:
error: '<anonymous>' is used uninitialized in this function [-Werror=uninitialized]
Why is this error, it is a defined way of initialize data to zero, right?If I change to :
void clear() { SA sa{}; m_s.a = sa; m_s.b = {}; ...}
instead, the release build will succeed.