[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#171123: marked as done (g++-3.2: incorrect use of default assignment operator?)



Your message dated 29 Nov 2002 14:41:40 +0100
with message-id <m3isyg5w8b.fsf@mira.informatik.hu-berlin.de>
and subject line Bug#171123: g++-3.2: incorrect use of default assignment operator?
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 29 Nov 2002 04:38:43 +0000
>From bab@ms.unimelb.edu.au Thu Nov 28 22:38:41 2002
Return-path: <bab@ms.unimelb.edu.au>
Received: from tincan.ms.unimelb.edu.au [128.250.24.200] 
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 18HcvI-0002zb-00; Thu, 28 Nov 2002 22:38:41 -0600
Received: from phoenix.ms.unimelb.edu.au (bab.ms.unimelb.edu.au [128.250.24.139])
	by tincan.ms.unimelb.edu.au (Postfix) with ESMTP
	id 2B9DE194E0; Fri, 29 Nov 2002 15:38:38 +1100 (EST)
Received: from bab by phoenix.ms.unimelb.edu.au with local (Exim 3.36 #1 (Debian))
	id 18Hctn-0008VM-00; Fri, 29 Nov 2002 15:37:07 +1100
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: Ben Burton <bab@debian.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: g++-3.2: incorrect use of default assignment operator?
X-Mailer: reportbug 2.9
Date: Fri, 29 Nov 2002 15:37:06 +1100
Message-Id: <[🔎] E18Hctn-0008VM-00@phoenix.ms.unimelb.edu.au>
Sender: Ben Burton <bab@ms.unimelb.edu.au>
Delivered-To: submit@bugs.debian.org
X-Spam-Status: No, hits=0.6 required=5.0
	tests=SPAM_PHRASE_00_01
	version=2.41
X-Spam-Level: 

Package: g++-3.2
Version: 1:3.2.1-1
Severity: normal

Hi.  Both g++-3.2 and g++-2.95 seem to have problems with the following
code.

  #include <iostream>

  struct Foo {
      int val;

      Foo(int newVal) {
          val = newVal;
      }

      Foo& operator = (const Foo& other) {
          val = 2;
      }
  };

  int main() {
      Foo foo(5);
      Foo bar = foo;

      std::cout << bar.val << std::endl;
      return 0;
  }

Under both compilers, the program compiles fine and then runs,
outputting the integer 5.

I would have expected a compile error, since the declaration
"Foo bar = foo;" tries to use the non-existant default constructor for
class Foo.

But even if it did build, I would have expected the program to output
the integer 2, since the = operator has been explicitly overridden.

What it seems to be doing is making its own default constructor and then
calling its own default assignment operator instead of the custom one
that has been defined.

Perhaps I'm just misunderstanding the finer details of the C++ specs?

Thanks - Ben.

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux phoenix 2.4.19-686 #1 Sun Oct 6 18:37:38 EST 2002 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages g++-3.2 depends on:
ii  gcc-3.2                       1:3.2.1-1  The GNU C compiler.
ii  gcc-3.2-base                  1:3.2.1-1  The GNU Compiler Collection (base 
ii  libc6                         2.3.1-5    GNU C Library: Shared libraries an
ii  libstdc++5-dev                1:3.2.1-1  The GNU stdc++ library version 3 (

-- no debconf information


---------------------------------------
Received: (at 171123-done) by bugs.debian.org; 29 Nov 2002 13:41:55 +0000
>From martin@v.loewis.de Fri Nov 29 07:41:55 2002
Return-path: <martin@v.loewis.de>
Received: from mailout11.sul.t-online.com [194.25.134.85] 
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 18HlP0-0006bE-00; Fri, 29 Nov 2002 07:41:55 -0600
Received: from fwd04.sul.t-online.de 
	by mailout11.sul.t-online.com with smtp 
	id 18HlOz-0001Og-01; Fri, 29 Nov 2002 14:41:53 +0100
Received: from mira.informatik.hu-berlin.de (03047300346-0001@[217.232.25.130]) by fmrl04.sul.t-online.com
	with esmtp id 18HlOl-1m4mpcC; Fri, 29 Nov 2002 14:41:39 +0100
Received: from mira.informatik.hu-berlin.de (localhost [127.0.0.1])
	by mira.informatik.hu-berlin.de (8.12.6/8.11.6/SuSE Linux 0.5) with ESMTP id gATDfg2i001794
	for <171123-done@bugs.debian.org>; Fri, 29 Nov 2002 14:41:42 +0100
Received: (from martin@localhost)
	by mira.informatik.hu-berlin.de (8.12.6/8.12.6/Submit) id gATDffHd001791;
	Fri, 29 Nov 2002 14:41:41 +0100
X-Authentication-Warning: mira.informatik.hu-berlin.de: martin set sender to martin@v.loewis.de using -f
Sender: martin@v.loewis.de
To: 171123-done@bugs.debian.org
Subject: Re: Bug#171123: g++-3.2: incorrect use of default assignment operator?
References: <[🔎] E18Hctn-0008VM-00@phoenix.ms.unimelb.edu.au>
	<[🔎] m3bs48x0ha.fsf@mira.informatik.hu-berlin.de>
	<[🔎] 20021129115241.GA19427@baasil.humbug.org.au>
From: martin@v.loewis.de (Martin v. =?iso-8859-15?q?L=F6wis?=)
Date: 29 Nov 2002 14:41:40 +0100
In-Reply-To: <[🔎] 20021129115241.GA19427@baasil.humbug.org.au>
Message-ID: <m3isyg5w8b.fsf@mira.informatik.hu-berlin.de>
Lines: 12
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Sender: 03047300346-0001@t-dialin.net
Delivered-To: 171123-done@bugs.debian.org
X-Spam-Status: No, hits=-11.0 required=5.0
	tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,
	      SPAM_PHRASE_00_01,USER_AGENT,X_AUTH_WARNING
	version=2.41
X-Spam-Level: 

Ben Burton <bab@debian.org> writes:

> Hmm, okay, my bad.  I'm reading through 12.8 now and it seems the
> implicit copy constructor is always available, not just when no other
> constructors are defined as I had thought.
> 
> If you agree with this then please go ahead and close this bug.

I certainly agree; there is no bug in the compiler.

Regards,
Martin



Reply to: