In a class that virtually inherits another class, the implicitly-defined assignment operator copies the object to the wrong location when called for an object of a more derived class. The attached example, when compiled with g++-3.3.1/g++-3.3.2, prints out "cb" instead of "bc".
Created attachment 5115 [details] Code for reproducing the bug
Indeed. This is a regression in 3.3.x and mainline with respect to previous versions. W.
Nathan -- One more ABI issue, I beleive. -- Gaby
Subject: Bug 13009 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-12-29 01:30:32 Modified files: gcc/cp : ChangeLog call.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/init: assign1.C Log message: PR c++/13009 * call.c (build_special_member_call): Do not assume that we have a pointer to the complete object in an assignment operator. PR c++/13009 * g++.dg/init/assign1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3836&r2=1.3837 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.446&r2=1.447 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3313&r2=1.3314 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/assign1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed in GCC 3.4.
Subject: Re: [3.3 regression] Implicitly-defined assignment operator writes to wrong memory "mmitchel at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes: | Fixed in GCC 3.4. Mark, As the author of this patch, do you think it is eligible for 3_3-branch? -- Gaby
I don't think Mark is on the cc: list for this bug. FWIW the patch does apply cleanly.
Subject: Bug 13009 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: gdr@gcc.gnu.org 2004-01-21 05:04:06 Modified files: gcc/cp : ChangeLog call.c Added files: gcc/testsuite/g++.dg/init: assign1.C Log message: Backport from mainline 2003-12-28 Mark Mitchell <mark@codesourcery.com> PR c++/13009 * call.c (build_special_member_call): Do not assume that we have a pointer to the complete object in an assignment operator. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.238&r2=1.3076.2.239 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.341.2.34&r2=1.341.2.35 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/assign1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.14.1
Fixed with backport from mainline.