------- Comment #12 from rguenth at gcc dot gnu dot org 2007-06-02 11:35 ------- Confirmed. Actually compiling Wrapper.cxx with -fstrict-aliasing is enough to trigger the failure.
In getItem() the difference is <bb 2>: - D.3769 = &_local_result + 4B; - this = (struct BaseClass *) D.3769; - this->d_self = 0B; + D.3821 = &_local_result + 4B; + this = (struct BaseClass *) D.3821; this = (struct NextClass *) &_local_result; iftmp.0 = (int (*__vtbl_ptr_type) (void) *) _ZTT9TestClass[2]; - this->_vptr.NextClass = iftmp.0; _local_result.D.2186._vptr.NextClass = &_ZTV9TestClass[4]; this->_vptr.NextClass = &_ZTV9TestClass[4]; D.2853 = at (cont->d_cont, ind) [return slot optimization]; in addItem() @@ -547,14 +541,12 @@ tmp.D.2186._vptr.NextClass = &_ZTV9TestClass[4]; this.9 = (struct NextClass *) &tmp; this.9->_vptr.NextClass = (int (*__vtbl_ptr_type) (void) *) _ZTT9TestClass[2] ; - D.4100 = &tmp + 4B; - this = (struct BaseClass *) D.4100; - D.4135 = this->d_self; - if (D.4135 != 0B) goto <L21>; else goto <L12>; + D.4160 = &tmp + 4B; + D.4195 = ((struct BaseClass *) D.4160)->d_self; + if (D.4195 != 0B) goto <L21>; else goto <L12>; <L21>:; - deleteRef (D.4135); - this->d_self = 0B; + deleteRef (D.4195); <L12>:; <<<exception object>>> = save_eptr.48; @@ -565,14 +557,12 @@ tmp.D.2186._vptr.NextClass = &_ZTV9TestClass[4]; this.9 = (struct NextClass *) &tmp; this.9->_vptr.NextClass = (int (*__vtbl_ptr_type) (void) *) _ZTT9TestClass[2] ; - D.4155 = &tmp + 4B; - this = (struct BaseClass *) D.4155; - D.4190 = this->d_self; - if (D.4190 != 0B) goto <L39>; else goto <L4>; + D.4215 = &tmp + 4B; + D.4250 = ((struct BaseClass *) D.4215)->d_self; + if (D.4250 != 0B) goto <L39>; else goto <L4>; <L39>:; - deleteRef (D.4190); - this->d_self = 0B; + deleteRef (D.4250); Note that making the inheritance non-virtual and fixing up TestClass::TestClass(TestClass::ior_t*) to initialize NextClass instead of BaseClass fixes the problem as well. So this may be a C++ frontend problem with virtual inheritance or an invalid testcase as well. (What happens if you initialize BaseClass from TestClass, but not NextClass -- if NextClass is default constructed then it will default construct BaseClass as well? C++ language lawyer question.) -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Keywords| |alias, wrong-code Last reconfirmed|0000-00-00 00:00:00 |2007-06-02 11:35:26 date| | Summary|-fstrict-aliasing |[4.2 Regression] -fstrict- |optimizations cause |aliasing optimizations cause |constructor not to run for |constructor not to run for |object causing segfault |object causing segfault http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32182