public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/9439: filebuf::sputbackc ignores beginning-of-file
@ 2003-02-03 14:26 Paolo Carlini
0 siblings, 0 replies; 5+ messages in thread
From: Paolo Carlini @ 2003-02-03 14:26 UTC (permalink / raw)
To: paolo; +Cc: gcc-prs
The following reply was made to PR libstdc++/9439; it has been noted by GNATS.
From: Paolo Carlini <pcarlini@unitus.it>
To: =?ISO-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>
Cc: paolo@gcc.gnu.org, bkoz@redhat.com, gcc-bugs@gcc.gnu.org,
nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: libstdc++/9439: filebuf::sputbackc ignores beginning-of-file
Date: Mon, 03 Feb 2003 15:21:09 +0100
P=E9tur Run=F3lfsson wrote:
>Hi,
> =20
>
>> Hi. I don't think there is a bug here: I cannot find in the
>> standard a specific prescription for the behaviour you
>> expect (in particular in 27.5.2.4.4) Can you?
>> =20
>>
>
>Yes. 27.8.1.4 [lib.filebuf.virtuals] p5 describes how pbackfail may
>put back the character c. The only cases that can apply here are the
>ones starting with
>
[snip]
Ok. I agree with your reading.
Therefore it seems that seekoff should be changed to return error in=20
this case. Then pbackfail would pay attention to the negative returned=20
value. The latter changes will also fix libstdc++/9425.
>> Indeed, sputbackc calls, as expected, pbackfail, which in=20
>>turns calls seekoff (fstream.tcc, line 218) (pay attention
>> to the preceding comment which means that this specific=20
>>situation was considered and _not_ supposed to lead to an
>> obvious failure).
>> =20
>>
>I read "at the beginning of the buffer" as simply meaning that
>gptr() =3D=3D eback(), not as "at the beginning of the file".
>
Yes, you are right.
Paolo.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=3Dview%20audit-trail&database=3D=
gcc&pr=3D9439
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: libstdc++/9439: filebuf::sputbackc ignores beginning-of-file
@ 2003-02-05 19:23 paolo
0 siblings, 0 replies; 5+ messages in thread
From: paolo @ 2003-02-05 19:23 UTC (permalink / raw)
To: bkoz, gcc-bugs, gcc-prs, paolo, peturr02
Synopsis: filebuf::sputbackc ignores beginning-of-file
State-Changed-From-To: feedback->closed
State-Changed-By: paolo
State-Changed-When: Wed Feb 5 19:23:48 2003
State-Changed-Why:
Fixed for 3.3 and 3.4.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9439
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: libstdc++/9439: filebuf::sputbackc ignores beginning-of-file
@ 2003-02-03 14:06 Pétur Runólfsson
0 siblings, 0 replies; 5+ messages in thread
From: Pétur Runólfsson @ 2003-02-03 14:06 UTC (permalink / raw)
To: paolo; +Cc: gcc-prs
The following reply was made to PR libstdc++/9439; it has been noted by GNATS.
From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>
To: <paolo@gcc.gnu.org>,
<bkoz@redhat.com>,
<gcc-bugs@gcc.gnu.org>,
<nobody@gcc.gnu.org>,
<gcc-gnats@gcc.gnu.org>
Cc:
Subject: RE: libstdc++/9439: filebuf::sputbackc ignores beginning-of-file
Date: Mon, 3 Feb 2003 13:56:12 -0000
Hi,
> Hi. I don't think there is a bug here: I cannot find in the
> standard a specific prescription for the behaviour you
> expect (in particular in 27.5.2.4.4) Can you?
Yes. 27.8.1.4 [lib.filebuf.virtuals] p5 describes how pbackfail may
put back the character c. The only cases that can apply here are the
ones starting with
If traits::eq_int_type( c ,traits::eof()) returns false and if the
function makes a putback position available
The meaning of "a putback position available" is defined in
27.5.1 [lib.streambuf.reqts] p3
If xnext is not a null pointer and xbeg < xnext for an input
sequence, then a putback position is available
and 27.5.1 [lib.streambuf.reqts] p2 states that xbeg points to the
beginning of an array that
represents, [...], a (sub)sequence of characters from the sequence
Finally, "the sequence" is defined in 27.8.1.1 [lib.filebuf] p1
The class basic_filebuf<charT,traits> associates both the input
sequence and the output sequence with a file.
> Indeed, sputbackc calls, as expected, pbackfail, which in=20
> turns calls seekoff (fstream.tcc, line 218) (pay attention
> to the preceding comment which means that this specific=20
> situation was considered and _not_ supposed to lead to an
> obvious failure).
I read "at the beginning of the buffer" as simply meaning that
gptr() =3D=3D eback(), not as "at the beginning of the file".
> The latter call then does _not_ fail and
> a put back buffer is created by _M_pback_create(), hosting
> the put back char, _exactly as happens_ when __testpb &&
> !__testeof && !__testeq, above.=20
> I agree that a few widespread implementations behave
> differently in this case, but we are, I maintain, in the
> realm of implementation defined behaviour.
> =20
> Paolo.
>=20
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=3Dview%20audit-trail&
database=3Dgcc&pr=3D9439
Petur
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: libstdc++/9439: filebuf::sputbackc ignores beginning-of-file
@ 2003-02-02 17:38 paolo
0 siblings, 0 replies; 5+ messages in thread
From: paolo @ 2003-02-02 17:38 UTC (permalink / raw)
To: bkoz, gcc-bugs, gcc-prs, nobody, paolo, peturr02
Synopsis: filebuf::sputbackc ignores beginning-of-file
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Sun Feb 2 17:38:23 2003
Responsible-Changed-Why:
Analyzed a bit.
State-Changed-From-To: open->feedback
State-Changed-By: paolo
State-Changed-When: Sun Feb 2 17:38:23 2003
State-Changed-Why:
Hi. I don't think there is a bug here: I cannot find in the
standard a specific prescription for the behaviour you
expect (in particular in 27.5.2.4.4) Can you?
Indeed, sputbackc calls, as expected, pbackfail, which in turns calls seekoff (fstream.tcc, line 218) (pay attention
to the preceding comment which means that this specific situation was considered and _not_ supposed to lead to an
obvious failure). The latter call then does _not_ fail and
a put back buffer is created by _M_pback_create(), hosting
the put back char, _exactly as happens_ when __testpb &&
!__testeof && !__testeq, above.
I agree that a few widespread implementations behave
differently in this case, but we are, I maintain, in the
realm of implementation defined behaviour.
Paolo.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9439
^ permalink raw reply [flat|nested] 5+ messages in thread
* libstdc++/9439: filebuf::sputbackc ignores beginning-of-file
@ 2003-01-25 12:06 peturr02
0 siblings, 0 replies; 5+ messages in thread
From: peturr02 @ 2003-01-25 12:06 UTC (permalink / raw)
To: gcc-gnats
>Number: 9439
>Category: libstdc++
>Synopsis: filebuf::sputbackc ignores beginning-of-file
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jan 25 12:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: peturr02@ru.is
>Release: gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
filebuf::sputbackc succeeds even if the filebuf is already at the beginning of the file. I don't think this makes much sense, sputbackc should fail at the beginning.
>How-To-Repeat:
See attachment.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="pbackfailbug2.cc"
Content-Disposition: inline; filename="pbackfailbug2.cc"
#include <fstream>
#include <cstdio>
using namespace std;
#undef NDEBUG
#include <cassert>
int main()
{
filebuf fbuf;
fbuf.open("pbackfailbug2.cc", ios_base::in);
int r = fbuf.sputbackc('a');
assert(r == EOF);
return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-02-05 19:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-03 14:26 libstdc++/9439: filebuf::sputbackc ignores beginning-of-file Paolo Carlini
-- strict thread matches above, loose matches on Subject: below --
2003-02-05 19:23 paolo
2003-02-03 14:06 Pétur Runólfsson
2003-02-02 17:38 paolo
2003-01-25 12:06 peturr02
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).