[Bug c++/45618] New: GCC 4.4.4 strstream and ios::internal flag
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 #include 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
[Bug c++/45618] GCC 4.4.4 strstream and ios::internal flag
--- Comment #3 from anhtuyen at ca dot ibm dot com 2010-09-09 20:12 --- (In reply to comment #2) > The output seems perfectly fine to me: at the end of Stage 1 we have 0x7b, > exactly what one gets from printf("%p", (void*)123), per 22.2.2.2.2/12, then, > per Table 61, padding is added after x, thus 0x@@7b. > Using the ios::internal flags, the format has changed from @@0x7b (gcc 4.1.2) to 0x@@7b (gcc 4.4.4) . One of them must be incorrect, at the very least. -- anhtuyen at ca dot ibm dot com changed: What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|INVALID | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45618