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

Bug#271300: marked as done (g++-3.4: ostreams misbehaving when used as temporaries)



Your message dated Sun, 26 Sep 2004 20:46:47 +0200
with message-id <16727.3735.955011.797154@gargle.gargle.HOWL>
and subject line Bug#271300: Not a bug -- sorry.
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; 12 Sep 2004 13:38:15 +0000
>From g_ogata@optushome.com.au Sun Sep 12 06:38:15 2004
Return-path: <g_ogata@optushome.com.au>
Received: from mail03.syd.optusnet.com.au [211.29.132.184] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1C6UYY-0008Fn-00; Sun, 12 Sep 2004 06:38:15 -0700
Received: from [127.0.0.1] (c220-237-16-232.belrs1.nsw.optusnet.com.au [220.237.16.232])
	by mail03.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id i8CDcCT3024001;
	Sun, 12 Sep 2004 23:38:12 +1000
Message-Id: <[🔎] 200409121338.i8CDcCT3024001@mail03.syd.optusnet.com.au>
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: George Ogata <g_ogata@optushome.com.au>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: g++-3.4: ostreams misbehaving when used as temporaries
X-Mailer: reportbug 2.64
Date: Sun, 12 Sep 2004 23:03:16 +1000
Delivered-To: submit@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_03_25 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-8.0 required=4.0 tests=BAYES_00,HAS_PACKAGE 
	autolearn=no version=2.60-bugs.debian.org_2004_03_25
X-Spam-Level: 

Package: g++-3.4
Version: 3.4.2-2
Severity: normal

This code:

----------------------------------------
#include <sstream>
#include <iostream>

int main() {
  std::cout << static_cast<std::ostringstream &>(std::ostringstream() << 'a' << "a").str() << std::endl;
  std::cout << static_cast<std::ostringstream &>(std::ostringstream() << "a" << "a").str() << std::endl;
}
----------------------------------------

.... prints under g++-3.3 and g++-3.4:

97a
0x804b6e0a

I expected:

aa
aa

(I get the expected behaviour with g++-2.95.)

Similar behaviour is exhibited if an ofstream is used in place of an
ostringstream:

----------------------------------------
#include <fstream>
#include <iostream>

int main() {
  std::ofstream("one") << 'a' << "a" << std::endl;
  std::ofstream("two") << "a" << "a" << std::endl;
}
----------------------------------------

g@crash:~/tmp$ cat one two
97a
0x8048b98a

It seems that if the first thing given to the ostream is a:
  -- char literal ('a'), the compiler treats it as an int (97)
  -- string literal ("a"), the compiler treats it as a void *
     (0x804b6e0a).

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.0
Locale: LANG=C, LC_CTYPE=C

Versions of packages g++-3.4 depends on:
ii  gcc-3.4                     3.4.2-2      The GNU C compiler
ii  gcc-3.4-base                3.4.2-2      The GNU Compiler Collection (base 
ii  libc6                       2.3.2.ds1-16 GNU C Library: Shared libraries an
ii  libstdc++6-dev              3.4.2-2      The GNU Standard C++ Library v3 (d

-- no debconf information

---------------------------------------
Received: (at 271300-done) by bugs.debian.org; 26 Sep 2004 18:46:56 +0000
>From doko@cs.tu-berlin.de Sun Sep 26 11:46:55 2004
Return-path: <doko@cs.tu-berlin.de>
Received: from mail.cs.tu-berlin.de [130.149.17.13] (root)
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1CBe2x-0003y8-00; Sun, 26 Sep 2004 11:46:55 -0700
Received: from mailhost.cs.tu-berlin.de (postfix@mail.cs.tu-berlin.de [130.149.17.13])
	by mail.cs.tu-berlin.de (8.9.3p2/8.9.3) with ESMTP id UAA10740;
	Sun, 26 Sep 2004 20:46:49 +0200 (MEST)
Received: from localhost (localhost [127.0.0.1])
	by mailhost.cs.tu-berlin.de (Postfix) with ESMTP id 3126EF217;
	Sun, 26 Sep 2004 20:46:49 +0200 (MEST)
Received: from mailhost.cs.tu-berlin.de ([127.0.0.1])
 by localhost (bueno [127.0.0.1]) (amavisd-new, port 10224) with ESMTP
 id 03387-43; Sun, 26 Sep 2004 20:46:48 +0200 (MEST)
Received: from bolero.cs.tu-berlin.de (bolero.cs.tu-berlin.de [130.149.19.1])
	by mailhost.cs.tu-berlin.de (Postfix) with ESMTP;
	Sun, 26 Sep 2004 20:46:48 +0200 (MEST)
Received: (from doko@localhost)
	by bolero.cs.tu-berlin.de (8.12.10+Sun/8.12.8/Submit) id i8QIkmG3024597;
	Sun, 26 Sep 2004 20:46:48 +0200 (MEST)
From: Matthias Klose <doko@cs.tu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <16727.3735.955011.797154@gargle.gargle.HOWL>
Date: Sun, 26 Sep 2004 20:46:47 +0200
To: George Ogata <g_ogata@optushome.com.au>, 271300-done@bugs.debian.org
Subject: Re: Bug#271300: Not a bug -- sorry.
In-Reply-To: <[🔎] 87acvv77ru.fsf@optushome.com.au>
References: <[🔎] 87acvv77ru.fsf@optushome.com.au>
X-Mailer: VM 7.03 under 21.4 (patch 6) "Common Lisp" XEmacs Lucid
X-Virus-Scanned: by amavisd-new at cs.tu-berlin.de
Delivered-To: 271300-done@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_03_25 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-5.0 required=4.0 tests=BAYES_01,HAS_BUG_NUMBER 
	autolearn=no version=2.60-bugs.debian.org_2004_03_25
X-Spam-Level: 

George Ogata writes:
> Apologies for the false alarm.  This truly fascinating "feature" of
> C++ is explained at:
> 
> http://tinyurl.com/5k5uo



Reply to: