public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17997] New: C++ ostringstream const char * interpreted as void *(?)
@ 2004-10-14 11:26 oyvind dot harboe at zylin dot com
  2004-10-14 12:58 ` [Bug libstdc++/17997] " bangerth at dealii dot org
  0 siblings, 1 reply; 2+ messages in thread
From: oyvind dot harboe at zylin dot com @ 2004-10-14 11:26 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug libstdc++/17997] C++ ostringstream const char * interpreted as void *(?)
  2004-10-14 11:26 [Bug c++/17997] New: C++ ostringstream const char * interpreted as void *(?) oyvind dot harboe at zylin dot com
@ 2004-10-14 12:58 ` bangerth at dealii dot org
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth at dealii dot org @ 2004-10-14 12:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-10-14 12:58 -------
This has been reported many times. In essence, you cannot use a 
temporary as a stringstream object as in 
  ostringstream() << something; 
The standard doesn't allow this. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
          Component|c++                         |libstdc++
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-10-14 12:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-14 11:26 [Bug c++/17997] New: C++ ostringstream const char * interpreted as void *(?) oyvind dot harboe at zylin dot com
2004-10-14 12:58 ` [Bug libstdc++/17997] " bangerth at dealii dot org

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).