- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Diffrerent output of the same program on HP aCC an...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2012 06:22 AM - edited 12-17-2012 06:46 AM
12-17-2012 06:22 AM - edited 12-17-2012 06:46 AM
Hi,
While migratining from deprecated std::strstream to std::stringstream we are faced with some problem related to std::stringstream.
The same program produces different output on HP aCC and on Intel/g++ compilers on Linux.
Here is some fragment of different outputs.
HP aCC
Compilation:
> aCC aaa21.cpp
> aCC +DD64 aaa21.cpp
[ Line-135, doStringStream] stream.str() = <xyz>
[ Line-136, doStringStream] stream.str().c_str() = <xyz>
[ Line-137, doStringStream] stream.str().data() = <xyz>
[ Line-139, doStringStream] stream.tellp() = <3>
[ Line-140, doStringStream] stream.str().size() = <3>
[ Line-141, doStringStream] stream.rdbuf()->str().size() = <3>
[ Line-142, doStringStream] stream.rdbuf()->in_avail() = <3>
Linux Intel/g++ compilers
> icpc aaa21.cpp
> g++ aaa21.cpp
[ Line-135, doStringStream] stream.str() = <xyzdefQQQQQQQQQQQQQQQQQQQ>
[ Line-136, doStringStream] stream.str().c_str() = <xyzdefQQQQQQQQQQQQQQQQQQQ>
[ Line-137, doStringStream] stream.str().data() = <xyzdefQQQQQQQQQQQQQQQQQQQ>
[ Line-139, doStringStream] stream.tellp() = <3>
[ Line-140, doStringStream] stream.str().size() = <25>
[ Line-141, doStringStream] stream.rdbuf()->str().size() = <25>
[ Line-142, doStringStream] stream.rdbuf()->in_avail() = <25>
The program and logs attached.
Any suggestions?
Thanks.
Alex
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2012 08:04 PM
12-19-2012 08:04 PM
SolutionThe 98 C++ Standard 27.7.1.3(16) says basic_stringbuf::setbuf is implementation defined.
As documented in basic_stringbuf(3C++), RW's basic_stringbuf::setbuf copies the current contents (empty) into the new buffer and uses the current pointer relative offsets.
(Contrary to the documentation, the buffer isn't owned, if not NULL.)
You may try this workaround:
#ifdef WORK
std::string str_tmp(pStringStream, i_size);
std::stringstream stream(str_tmp);
#else
std::stringstream stream;
stream.rdbuf()->pubsetbuf(pStringStream, i_size);
#endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2012 08:53 PM
12-19-2012 08:53 PM
Re: Different output of the same program on HP aCC and Linux (Intel/g++) for std::stringstream
Dennis, thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2012 09:54 PM
12-19-2012 09:54 PM
Re: Different output of the same program on HP aCC and Linux (Intel/g++) for std::stringstream
>thank you.
If you're happy please also assign kudos.