This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17997] New: C++ ostringstream const char * interpreted as void *(?)
- From: "oyvind dot harboe at zylin dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Oct 2004 11:26:43 -0000
- Subject: [Bug c++/17997] New: C++ ostringstream const char * interpreted as void *(?)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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