This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/10975] New: incorrect initial ostringstream::tellp()
- From: "from-bugzilla at geek-central dot gen dot nz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 May 2003 00:24:43 -0000
- Subject: [Bug c++/10975] New: incorrect initial ostringstream::tellp()
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10975
Summary: incorrect initial ostringstream::tellp()
Product: gcc
Version: 3.2.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: from-bugzilla@geek-central.gen.nz
CC: gcc-bugs@gcc.gnu.org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
When a new ostringstream object is created but nothing has been written
to it yet, the tellp() method returns an offset of -1, instead of 0.
Example program:
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
int main
(
int argc,
const char * const * argv,
const char * const * envp
)
{
std::ostringstream Stream1;
std::ofstream Stream2("junk.tmp");
#if 0
Stream1 << " ";
Stream2 << " ";
#endif
std::cout
<< "sstream.tellp() = "
<< Stream1.tellp()
<< ", fstream.tellp() = "
<< Stream2.tellp()
"test.cpp" 27L, 434C written
$ g++ -o test test.cpp
$ less test.cpp
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
int main
(
int argc,
const char * const * argv,
const char * const * envp
)
{
std::ostringstream Stream1;
std::ofstream Stream2("junk.tmp");
#if 0
Stream1 << " ";
Stream2 << " ";
#endif
std::cout
<< "sstream.tellp() = "
<< Stream1.tellp()
<< ", fstream.tellp() = "
<< Stream2.tellp()
<< std::endl;
return
0;
} /*main*/
Output from above:
sstream.tellp() = -1, fstream.tellp() = 0
If you change the "#if 0" line to "#if 1", the output becomes
sstream.tellp() = 1, fstream.tellp() = 1
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.