You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@stdcxx.apache.org by "Martin Sebor (JIRA)" <ji...@apache.org> on 2008/04/22 03:49:21 UTC
[jira] Closed: (STDCXX-59) std::istream::getline(char*, size_type)
doesn't store NUL on failure
[ https://issues.apache.org/jira/browse/STDCXX-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Sebor closed STDCXX-59.
------------------------------
Regression test added in [r650353|http://svn.apache.org/viewvc?rev=650353&view=rev].
> std::istream::getline(char*, size_type) doesn't store NUL on failure
> --------------------------------------------------------------------
>
> Key: STDCXX-59
> URL: https://issues.apache.org/jira/browse/STDCXX-59
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 27. Input/Output
> Affects Versions: 4.1.2
> Environment: all
> Reporter: Martin Sebor
> Assignee: Martin Sebor
> Fix For: 4.1.3
>
>
> The program below aborts at runtime. According to lib.istream.unformatted, p20:
> "[getline...] stores a null character (using charT()) into the next successive location of the array."
> $ cat t.cpp && nice make t -r && ./t
> #include <cassert>
> #include <sstream>
> int main ()
> {
> std::istringstream strm;
> strm.setstate (strm.failbit);
> char s [3] = { 'x', 'y', 'z' };
> strm.getline (s, 2);
> assert ('\0' == s [0]);
> assert ('y' == s [1]);
> assert ('z' == s [2]);
> }
> gcc -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG -pthreads -D_RWSTD_USE_CONFIG -I/build/sebor/gcc-3.4.3-15s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include -pedantic -nostdinc++ -g -Wall -W -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long t.cpp
> gcc t.o -o t -L/build/sebor/gcc-3.4.3-15s/rwtest -lrwtest15s -pthreads -L/build/sebor/gcc-3.4.3-15s/lib -lstd15s -lsupc++ -lm
> Assertion failed: '\0' == s [0], file t.cpp, line 13
> Abort (core dumped)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.