Bug 13009 - [3.3 regression] Implicitly-defined assignment operator writes to wrong memory
Summary: [3.3 regression] Implicitly-defined assignment operator writes to wrong memory
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.2
: P2 critical
Target Milestone: 3.3.3
Assignee: Not yet assigned to anyone
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
 
Reported: 2003-11-11 15:37 UTC by oldfishdontdie
Modified: 2004-01-21 05:04 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-12-16 20:26:36


Attachments
Code for reproducing the bug (252 bytes, text/plain)
2003-11-11 15:46 UTC, oldfishdontdie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description oldfishdontdie 2003-11-11 15:37:59 UTC
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".
Comment 1 oldfishdontdie 2003-11-11 15:46:24 UTC
Created attachment 5115 [details]
Code for reproducing the bug
Comment 2 Wolfgang Bangerth 2003-11-11 16:29:07 UTC
Indeed. This is a regression in 3.3.x and mainline with respect to
previous versions.

W.
Comment 3 Gabriel Dos Reis 2003-12-24 21:54:48 UTC
Nathan --
One more ABI issue, I beleive.

-- Gaby
Comment 4 GCC Commits 2003-12-29 01:30:37 UTC
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

Comment 5 Mark Mitchell 2003-12-29 01:34:01 UTC
Fixed in GCC 3.4.
Comment 6 Gabriel Dos Reis 2004-01-01 00:17:55 UTC
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
Comment 7 Dara Hazeghi 2004-01-21 03:39:42 UTC
I don't think Mark is on the cc: list for this bug. FWIW the patch does apply cleanly.
Comment 8 GCC Commits 2004-01-21 05:04:14 UTC
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

Comment 9 Gabriel Dos Reis 2004-01-21 05:04:36 UTC
Fixed with backport from mainline.