The following code can be compiled with either g++ (GCC) 4.1.2 or g++ (GCC)
4.4.4.
When running the executable with non-static library, it produces different
output.

The output linked with strstream on g++ (GCC) 4.4.4 seems to be incorrect.

CODE:
/* File name iosflag.C */

#include <iostream>
#include <strstream>
using namespace std;

int main()
{

    char string[1024];

    char out_buffer[1024];
    strstream io(out_buffer, 1024, ios::in|ios::out);

    io.ios::fill('@');
    io.flags(ios::internal);
    io.width( 10 );
    io << (void *) 123 << ' ';
    io >> string ;
    cout << "String: " << string << endl;
}

COMPILE:
g++ -o iosflag ./iosflag.C

RUN:
./iosflag


EXPECTED RESULTS:
String: @@@@@@0x7b

ACTUAL RESULTS:
String: 0x@@@@@@7b

NOTE: strstream on g++ (GCC) 4.1.2 produce correct result.


-- 
           Summary: GCC 4.4.4 strstream and ios::internal flag
           Product: gcc
           Version: 4.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anhtuyen at ca dot ibm dot com


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

Reply via email to