public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "oyvind dot harboe at zylin dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/17997] New: C++ ostringstream const char * interpreted as void *(?)
Date: Thu, 14 Oct 2004 11:26:00 -0000	[thread overview]
Message-ID: <20041014112628.17997.oyvind.harboe@zylin.com> (raw)

The test program below produces the following output below.

I tested this with Visual C++ and it does outputs "abcdef" for both cases.

=================
$ g++ -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/specs
Configured with: /gcc/gcc-3.3.3-3/configure --verbose --prefix=/usr --exec-
prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --
mandir=/usr/share/man --infodir=/usr/share/info --enable-
languages=c,ada,c++,d,f77,java,objc,pascal --enable-nls --without-included-
gettext --enable-libgcj --with-system-zlib --enable-interpreter --enable-
threads=posix --enable-java-gc=boehm --enable-sjlj-exceptions --disable-version-
specific-runtime-libs --disable-win32-registry
Thread model: posix
gcc version 3.3.3 (cygwin special)
$ g++ test.cc

oharboe@lair ~
$ ./a.exe 
0x434004def

abcdef
=====




#include <sstream>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iostream>
#include <string>

using namespace std;
void executeBuffer(const ostream & cmd)
{
  string t=static_cast<const ostringstream &>(cmd).str();

  printf("%s\n", t.c_str());
}
	
int main(char **argv, int argc)
{
  executeBuffer(ostringstream() << "abc" << "def\n");
  ostringstream t;
  t<<"abc" << "def\n" ;
  executeBuffer(t);

  return 0;
}

-- 
           Summary: C++ ostringstream const char * interpreted as void *(?)
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: oyvind dot harboe at zylin dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17997


             reply	other threads:[~2004-10-14 11:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-14 11:26 oyvind dot harboe at zylin dot com [this message]
2004-10-14 12:58 ` [Bug libstdc++/17997] " bangerth at dealii dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041014112628.17997.oyvind.harboe@zylin.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).