consider such code:
struct foo { int a; foo() { = 17; } //void clear() { = 17; } }; class boo { public: void f() { foo = foo(); //foo.clear(); } private: foo foo; }; i compiled gcc (-std=c++11), , according logs in f function foo not reintialized foo = foo(); expression, works fine if uncomment code clear.
is code foo = foo(); should translated to
foo tmp; memcpy(&foo, &tmp, sizeof(foo)); or compiler can kind of optimization, , after foo = foo(); got garbage in foo?
this:
foo = foo(); should construct new instance of class foo.
it creates new object, allocating memory , initializing data member a 17.
ps: error somewhere else, , since refused provide minimal example, can't tell where.
Comments
Post a Comment