This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

libstdc++/4083: input stream with field width() set reads too much to std::string



>Number:         4083
>Category:       libstdc++
>Synopsis:       input stream with field width()  set reads too much to std::string
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 22 12:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     David Hedbor
>Release:        3.0.1
>Organization:
>Environment:
Mandrake Cooker linux install, glibc 2.2.3
>Description:
When I set the width of an input stream and when use operator >> to an std::string, one byte too many is read. I.e
"ifs.width(8); ifs >> str;" reads 8 bytes if str is an std::string but 7 bytes if it's a char *. gcc 2.96 (mandrake) and egcs-2.91.66 do now show this problem.
>How-To-Repeat:
Compile and run the attached program.
>Fix:
Unknown. A workaround is to use a temporary char * for reading into.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.cpp"

I2luY2x1ZGUgPGZzdHJlYW0+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxjc3RkaW8+Cgov
LyBCdWcgaXMgdGhhdCA+PiB0byBhIHN0ZDo6c3RyaW5nLCB3aXRoIHdpZHRoKCkgc2V0LCByZWFk
cyBvbmUgdG9vIG1hbnkgYnl0ZXMuIAppbnQgbWFpbigpIHsKICBzdGQ6OnN0cmluZyBzdHI7CiAg
Y2hhciBzdHIyWzhdOwogIHN0ZDo6aWZzdHJlYW0gaWZzKCJ0ZXN0LmNwcCIsIHN0ZDo6aW9zOjpp
bik7CiAgaWZzLndpZHRoKDgpOwogIGlmcyA+PiBzdHI7CiAgc3RkOjppZnN0cmVhbSBpZnMyKCJ0
ZXN0LmNwcCIsIHN0ZDo6aW9zOjppbik7CiAgaWZzMi53aWR0aCg4KTsKICBpZnMyID4+IHN0cjI7
CiAgcHJpbnRmKCJzdHIubGVuZ3RoKCkgPSAlZCwgc3RybGVuKHN0ci5jX3N0cigpKSA9ICVkXG5z
dHJsZW4oc3RyMikgPT0gJWRcbiIsCgkgc3RyLmxlbmd0aCgpLCBzdHJsZW4oc3RyLmNfc3RyKCkp
LCBzdHJsZW4oc3RyMikpOwp9Cg==


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]