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

Bug#319744: marked as done (g++-4.0: cout << &charvar is scrambled)



Your message dated Sun, 24 Jul 2005 20:58:57 +0200
with message-id <87pst8t4i6.fsf@debian.org>
and subject line Bug#319744: g++-4.0: cout << &charvar is scrambled
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; 24 Jul 2005 13:44:12 +0000
>From gerhard.horecky@inode.at Sun Jul 24 06:44:12 2005
Return-path: <gerhard.horecky@inode.at>
Received: from master.debian.org [146.82.138.7] 
	by spohr.debian.org with esmtp (Exim 3.36 1 (Debian))
	id 1Dwgm4-00027Y-00; Sun, 24 Jul 2005 06:44:12 -0700
Received: from 62-99-165-149.dynamic.adsl-line.inode.at ([192.168.1.2]) [62.99.165.149] 
	by master.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1Dwgm3-0007dq-00; Sun, 24 Jul 2005 08:44:11 -0500
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
From: Gerhard Horecky <gerhard.horecky@inode.at>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: g++-4.0: cout << &charvar is scrambled
X-Mailer: reportbug 3.15
Date: Sun, 24 Jul 2005 15:46:40 +0200
X-Debbugs-Cc: gerhard.horecky@inode.at
Message-Id: <[🔎] E1Dwgm3-0007dq-00@master.debian.org>
Delivered-To: submit@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-9.0 required=4.0 tests=BAYES_00,HAS_PACKAGE,
	OUR_MTA_MSGID,X_DEBBUGS_CC autolearn=ham 
	version=2.60-bugs.debian.org_2005_01_02

Package: g++-4.0
Version: 4.0.1-2
Severity: normal

If one tries to output an address of a character variable or a pointer
to a character variable, the output is scrambled.

Consider the following test program:

#include <iostream>
#include <stdio.h>

main () {

char a = 'a';
bool b = 0;
short s = 0;
int i = 4711;
char *pa = &a;
int *pi = &i;
void *vpa = &a;

printf("printf Output of address of i is %lx\n", &i);
printf("printf Output of pointer to i is %lx\n", pi);
std::cout << "cout Output of pointer to i is " << pi << '\n';
std::cout << "cout Output of address of i is " << &i << '\n';
std::cout << "cout Output of pointer to  a is " << pa << '\n';
std::cout << "cout Output of void pointer to  a is " << vpa << '\n';
std::cout << "cout Output of address of a is " << &a << '\n';
std::cout << "cout Output of address of a is ";
std::cout << &a;
std::cout << '\n';
std::cout << "cout Output of address of b is " << &b << '\n';
std::cout << "cout Output of address of s is " << &s << '\n';

printf("printf Output of address of a is %lx\n", &a);

}

It has the following output:

printf Output of address of i is bffff874
printf Output of pointer to i is bffff874
cout Output of pointer to i is 0xbffff874
cout Output of address of i is 0xbffff874
cout Output of pointer to  a is a{øÿ¿tøÿ¿{øÿ¿èøÿ¿téÙ·
cout Output of void pointer to  a is 0xbffff87b
cout Output of address of a is a{øÿ¿tøÿ¿{øÿ¿èøÿ¿téÙ·
cout Output of address of a is a{øÿ¿tøÿ¿{øÿ¿èøÿ¿téÙ·
cout Output of address of b is 0xbffff87a
cout Output of address of s is 0xbffff878
printf Output of address of a is bffff87b


As one can see with od -c, there are some unprintable characters:

0000000   p   r   i   n   t   f       O   u   t   p   u   t       o   f
0000020       a   d   d   r   e   s   s       o   f       i       i   s
0000040       b   f   f   f   f   8   7   4  \n   p   r   i   n   t   f
0000060       O   u   t   p   u   t       o   f       p   o   i   n   t
0000100   e   r       t   o       i       i   s       b   f   f   f   f
0000120   8   7   4  \n   c   o   u   t       O   u   t   p   u   t    
0000140   o   f       p   o   i   n   t   e   r       t   o       i    
0000160   i   s       0   x   b   f   f   f   f   8   7   4  \n   c   o
0000200   u   t       O   u   t   p   u   t       o   f       a   d   d
0000220   r   e   s   s       o   f       i       i   s       0   x   b
0000240   f   f   f   f   8   7   4  \n   c   o   u   t       O   u   t
0000260   p   u   t       o   f       p   o   i   n   t   e   r       t
0000300   o           a       i   s       a   { 370 377 277   t 370 377
0000320 277   { 370 377 277 350 370 377 277   t 351 331 267 001  \n   c
0000340   o   u   t       O   u   t   p   u   t       o   f       v   o
0000360   i   d       p   o   i   n   t   e   r       t   o           a
0000400       i   s       0   x   b   f   f   f   f   8   7   b  \n   c
0000420   o   u   t       O   u   t   p   u   t       o   f       a   d
0000440   d   r   e   s   s       o   f       a       i   s       a   {
0000460 370 377 277   t 370 377 277   { 370 377 277 350 370 377 277   t
0000500 351 331 267 001  \n   c   o   u   t       O   u   t   p   u   t
0000520       o   f       a   d   d   r   e   s   s       o   f       a
0000540       i   s       a   { 370 377 277   t 370 377 277   { 370 377
0000560 277 350 370 377 277   t 351 331 267 001  \n   c   o   u   t    
0000600   O   u   t   p   u   t       o   f       a   d   d   r   e   s
0000620   s       o   f       b       i   s       0   x   b   f   f   f
0000640   f   8   7   a  \n   c   o   u   t       O   u   t   p   u   t
0000660       o   f       a   d   d   r   e   s   s       o   f       s
0000700       i   s       0   x   b   f   f   f   f   8   7   8  \n   p
0000720   r   i   n   t   f       O   u   t   p   u   t       o   f    
0000740   a   d   d   r   e   s   s       o   f       a       i   s    
0000760   b   f   f   f   f   8   7   b  \n
0000771

Initially, I started with stable, i.e. g++-3.3 and g++3.4. Those
versions have the same Problem.  Perhaps it is located in libc6?

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.11-1-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

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

g++-4.0 recommends no packages.

-- no debconf information

---------------------------------------
Received: (at 319744-done) by bugs.debian.org; 24 Jul 2005 18:59:32 +0000
>From falk@debian.org Sun Jul 24 11:59:32 2005
Return-path: <falk@debian.org>
Received: from smtp05.web.de [217.72.192.209] 
	by spohr.debian.org with esmtp (Exim 3.36 1 (Debian))
	id 1DwlhE-0000bl-00; Sun, 24 Jul 2005 11:59:32 -0700
Received: from [82.82.254.175] (helo=juist)
	by smtp05.web.de with asmtp (TLSv1:DES-CBC3-SHA:168)
	(WEB.DE 4.105 #297)
	id 1Dwlgh-0004Ea-00
	for 319744-done@bugs.debian.org; Sun, 24 Jul 2005 20:58:59 +0200
Received: from falk by juist with local (Exim 4.52)
	id 1Dwlgf-00025L-6y
	for 319744-done@bugs.debian.org; Sun, 24 Jul 2005 20:58:57 +0200
To: 319744-done@bugs.debian.org
Subject: Re: Bug#319744: g++-4.0: cout << &charvar is scrambled
References: <[🔎] E1Dwgm3-0007dq-00@master.debian.org>
From: Falk Hueffner <falk@debian.org>
X-Face: "iUeUu$b*W_"w?tV83Y3*r:`rh&dRv}$YnZ3,LVeCZSYVuf[Gpo*5%_=/\_!gc_,SS}[~xZ
 wY77I-M)xHIx:2f56g%/`SOw"Dx%4Xq0&f\Tj~>|QR|vGlU}TBYhiG(K:2<T^
Date: Sun, 24 Jul 2005 20:58:57 +0200
In-Reply-To: <[🔎] E1Dwgm3-0007dq-00@master.debian.org> (Gerhard Horecky's
 message of "Sun, 24 Jul 2005 15:46:40 +0200")
Message-ID: <87pst8t4i6.fsf@debian.org>
User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.5 (cilantro, linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Sender: falk@debian.org
X-Sender: falk.hueffner@web.de
Delivered-To: 319744-done@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-6.0 required=4.0 tests=BAYES_00,HAS_BUG_NUMBER 
	autolearn=no version=2.60-bugs.debian.org_2005_01_02

Gerhard Horecky <gerhard.horecky@inode.at> writes:

> If one tries to output an address of a character variable or a pointer
> to a character variable, the output is scrambled.

The compiler cannot read your mind; it doesn't know whether your
intention is to output a character string, or the address of a pointer
to char, so it assumes the former. This seems like a good idea to me;
I prefer to see "foo" for cout << "foo" instead of something like
0x1837506.

-- 
	Falk



Reply to: