[jira] Commented: (STDCXX-250) std::operator>>(istream&, string&) fails to set failbit after it extracts 0 characters

2007-10-10 Thread Farid Zaripov (JIRA)

[ 
https://issues.apache.org/jira/browse/STDCXX-250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12533791
 ] 

Farid Zaripov commented on STDCXX-250:
--

But in this test program the operator>>() extracted one character ('x').

Anyway failbit is not set even in case when no characters extracted.

> std::operator>>(istream&, string&) fails to set failbit after it extracts 0 
> characters
> --
>
> Key: STDCXX-250
> URL: https://issues.apache.org/jira/browse/STDCXX-250
> Project: C++ Standard Library
>  Issue Type: Bug
>  Components: 27. Input/Output
>Affects Versions: 4.1.2, 4.1.3
> Environment: all
>Reporter: Martin Sebor
>Priority: Minor
>
> 21.3.7.9, p3 says about the string extractor: "If the function extracts no 
> characters, it calls is.setstate(ios::failbit), which may throw 
> ios_base::failure (27.4.4.3)." The test program below shows that in 
> unbuffered mode stdcxx fails to do so when an exception is thrown during the 
> third call to underflow().
> $ cat v.cpp && make v && ./v
> #include 
> #include 
> #include 
> #include 
> int main ()
> {
> struct: std::streambuf {
> int_type underflow () {
> static int i = 0;
> // i == 0: sgect() invoked from sentry ctor
> // i == 1: sgetc() invoked from operator>>()
> // i == 2: sbumpc() invoked from operator>>()
> return 1 < i++ ? throw i : 'x';
> }
> } buf;
> std::istream is (&buf);
> std::string s;
> is >> s;
> std::printf ("state = %c%c%c, string = \"%s\" (length %u)\n",
>  is.rdstate () & is.badbit ? 'B' : '-',
>  is.rdstate () & is.eofbit ? 'E' : '-',
>  is.rdstate () & is.failbit ? 'F' : '-',
>  s.c_str (), s.size ());
> assert ("x" == s);
> assert ((is.failbit | is.badbit) == is.rdstate ());
> }
> gcc -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG   -pthreads 
> -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/include 
> -I/build/sebor/gcc-4.1.0-15s/include -I/build/sebor/dev/stdlib/../rwtest 
> -I/build/sebor/dev/stdlib/../rwtest/include 
> -I/build/sebor/dev/stdlib/tests/include  -pedantic -nostdinc++ -g  -W -Wall 
> -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long  v.cpp
> gcc v.o -o v -L/build/sebor/gcc-4.1.0-15s/rwtest -lrwtest15s -pthreads 
> -L/build/sebor/gcc-4.1.0-15s/lib -lstd15s  -lsupc++ -lm
> state = B--, string = "x" (length 1)
> Assertion failed: (is.failbit | is.badbit) == is.rdstate (), file v.cpp, line 
> 30
> Abort (core dumped)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (STDCXX-250) std::operator>>(istream&, string&) fails to set failbit after it extracts 0 characters

2007-10-10 Thread Farid Zaripov (JIRA)

[ 
https://issues.apache.org/jira/browse/STDCXX-250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12533797
 ] 

Farid Zaripov commented on STDCXX-250:
--

ChangeLog:
  STDCXX-250
  * istream.cc (operator>>): Move counter __i out from the try/catch block
  and rename to __gcount for consistency with getline(). Set ios_base::failbit
  if no characters extracted.


> std::operator>>(istream&, string&) fails to set failbit after it extracts 0 
> characters
> --
>
> Key: STDCXX-250
> URL: https://issues.apache.org/jira/browse/STDCXX-250
> Project: C++ Standard Library
>  Issue Type: Bug
>  Components: 27. Input/Output
>Affects Versions: 4.1.2, 4.1.3
> Environment: all
>Reporter: Martin Sebor
>Priority: Minor
> Fix For: 4.2.1
>
> Attachments: istream.cc.diff
>
>
> 21.3.7.9, p3 says about the string extractor: "If the function extracts no 
> characters, it calls is.setstate(ios::failbit), which may throw 
> ios_base::failure (27.4.4.3)." The test program below shows that in 
> unbuffered mode stdcxx fails to do so when an exception is thrown during the 
> third call to underflow().
> $ cat v.cpp && make v && ./v
> #include 
> #include 
> #include 
> #include 
> int main ()
> {
> struct: std::streambuf {
> int_type underflow () {
> static int i = 0;
> // i == 0: sgect() invoked from sentry ctor
> // i == 1: sgetc() invoked from operator>>()
> // i == 2: sbumpc() invoked from operator>>()
> return 1 < i++ ? throw i : 'x';
> }
> } buf;
> std::istream is (&buf);
> std::string s;
> is >> s;
> std::printf ("state = %c%c%c, string = \"%s\" (length %u)\n",
>  is.rdstate () & is.badbit ? 'B' : '-',
>  is.rdstate () & is.eofbit ? 'E' : '-',
>  is.rdstate () & is.failbit ? 'F' : '-',
>  s.c_str (), s.size ());
> assert ("x" == s);
> assert ((is.failbit | is.badbit) == is.rdstate ());
> }
> gcc -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG   -pthreads 
> -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/include 
> -I/build/sebor/gcc-4.1.0-15s/include -I/build/sebor/dev/stdlib/../rwtest 
> -I/build/sebor/dev/stdlib/../rwtest/include 
> -I/build/sebor/dev/stdlib/tests/include  -pedantic -nostdinc++ -g  -W -Wall 
> -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long  v.cpp
> gcc v.o -o v -L/build/sebor/gcc-4.1.0-15s/rwtest -lrwtest15s -pthreads 
> -L/build/sebor/gcc-4.1.0-15s/lib -lstd15s  -lsupc++ -lm
> state = B--, string = "x" (length 1)
> Assertion failed: (is.failbit | is.badbit) == is.rdstate (), file v.cpp, line 
> 30
> Abort (core dumped)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (STDCXX-250) std::operator>>(istream&, string&) fails to set failbit after it extracts 0 characters

2007-11-28 Thread Farid Zaripov (JIRA)

[ 
https://issues.apache.org/jira/browse/STDCXX-250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12546300
 ] 

Farid Zaripov commented on STDCXX-250:
--

Does the term "extracted" means that the gptr() should be shifted by one 
position?


> std::operator>>(istream&, string&) fails to set failbit after it extracts 0 
> characters
> --
>
> Key: STDCXX-250
> URL: https://issues.apache.org/jira/browse/STDCXX-250
> Project: C++ Standard Library
>  Issue Type: Bug
>  Components: 27. Input/Output
>Affects Versions: 4.1.2, 4.1.3
> Environment: all
>Reporter: Martin Sebor
>Assignee: Farid Zaripov
>Priority: Minor
> Fix For: 4.2.1
>
> Attachments: istream.cc.diff
>
>
> 21.3.7.9, p3 says about the string extractor: "If the function extracts no 
> characters, it calls is.setstate(ios::failbit), which may throw 
> ios_base::failure (27.4.4.3)." The test program below shows that in 
> unbuffered mode stdcxx fails to do so when an exception is thrown during the 
> third call to underflow().
> $ cat v.cpp && make v && ./v
> #include 
> #include 
> #include 
> #include 
> int main ()
> {
> struct: std::streambuf {
> int_type underflow () {
> static int i = 0;
> // i == 0: sgect() invoked from sentry ctor
> // i == 1: sgetc() invoked from operator>>()
> // i == 2: sbumpc() invoked from operator>>()
> return 1 < i++ ? throw i : 'x';
> }
> } buf;
> std::istream is (&buf);
> std::string s;
> is >> s;
> std::printf ("state = %c%c%c, string = \"%s\" (length %u)\n",
>  is.rdstate () & is.badbit ? 'B' : '-',
>  is.rdstate () & is.eofbit ? 'E' : '-',
>  is.rdstate () & is.failbit ? 'F' : '-',
>  s.c_str (), s.size ());
> assert ("x" == s);
> assert ((is.failbit | is.badbit) == is.rdstate ());
> }
> gcc -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG   -pthreads 
> -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/include 
> -I/build/sebor/gcc-4.1.0-15s/include -I/build/sebor/dev/stdlib/../rwtest 
> -I/build/sebor/dev/stdlib/../rwtest/include 
> -I/build/sebor/dev/stdlib/tests/include  -pedantic -nostdinc++ -g  -W -Wall 
> -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long  v.cpp
> gcc v.o -o v -L/build/sebor/gcc-4.1.0-15s/rwtest -lrwtest15s -pthreads 
> -L/build/sebor/gcc-4.1.0-15s/lib -lstd15s  -lsupc++ -lm
> state = B--, string = "x" (length 1)
> Assertion failed: (is.failbit | is.badbit) == is.rdstate (), file v.cpp, line 
> 30
> Abort (core dumped)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (STDCXX-250) std::operator>>(istream&, string&) fails to set failbit after it extracts 0 characters

2007-11-28 Thread Martin Sebor (JIRA)

[ 
https://issues.apache.org/jira/browse/STDCXX-250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12546422
 ] 

Martin Sebor commented on STDCXX-250:
-

gptr() may stay null in unbuffered mode so I don't think "extracted" 
necessarily implies incrementing gptr(). To extract a character from a sequence 
means to advance to the next position in the sequence so that the subsequent 
extraction will return the character at the next position (or EOF).

> std::operator>>(istream&, string&) fails to set failbit after it extracts 0 
> characters
> --
>
> Key: STDCXX-250
> URL: https://issues.apache.org/jira/browse/STDCXX-250
> Project: C++ Standard Library
>  Issue Type: Bug
>  Components: 27. Input/Output
>Affects Versions: 4.1.2, 4.1.3
> Environment: all
>Reporter: Martin Sebor
>Assignee: Farid Zaripov
>Priority: Minor
> Fix For: 4.2.1
>
> Attachments: istream.cc.diff
>
>
> 21.3.7.9, p3 says about the string extractor: "If the function extracts no 
> characters, it calls is.setstate(ios::failbit), which may throw 
> ios_base::failure (27.4.4.3)." The test program below shows that in 
> unbuffered mode stdcxx fails to do so when an exception is thrown during the 
> third call to underflow().
> $ cat v.cpp && make v && ./v
> #include 
> #include 
> #include 
> #include 
> int main ()
> {
> struct: std::streambuf {
> int_type underflow () {
> static int i = 0;
> // i == 0: sgect() invoked from sentry ctor
> // i == 1: sgetc() invoked from operator>>()
> // i == 2: sbumpc() invoked from operator>>()
> return 1 < i++ ? throw i : 'x';
> }
> } buf;
> std::istream is (&buf);
> std::string s;
> is >> s;
> std::printf ("state = %c%c%c, string = \"%s\" (length %u)\n",
>  is.rdstate () & is.badbit ? 'B' : '-',
>  is.rdstate () & is.eofbit ? 'E' : '-',
>  is.rdstate () & is.failbit ? 'F' : '-',
>  s.c_str (), s.size ());
> assert ("x" == s);
> assert ((is.failbit | is.badbit) == is.rdstate ());
> }
> gcc -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG   -pthreads 
> -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/include 
> -I/build/sebor/gcc-4.1.0-15s/include -I/build/sebor/dev/stdlib/../rwtest 
> -I/build/sebor/dev/stdlib/../rwtest/include 
> -I/build/sebor/dev/stdlib/tests/include  -pedantic -nostdinc++ -g  -W -Wall 
> -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long  v.cpp
> gcc v.o -o v -L/build/sebor/gcc-4.1.0-15s/rwtest -lrwtest15s -pthreads 
> -L/build/sebor/gcc-4.1.0-15s/lib -lstd15s  -lsupc++ -lm
> state = B--, string = "x" (length 1)
> Assertion failed: (is.failbit | is.badbit) == is.rdstate (), file v.cpp, line 
> 30
> Abort (core dumped)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.