This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/6360: Wrong workaround in char_traits.h - ignore stops on \0xff
- From: mki at maconomy dot dk
- To: gcc-gnats at gcc dot gnu dot org
- Date: 18 Apr 2002 14:57:56 -0000
- Subject: libstdc++/6360: Wrong workaround in char_traits.h - ignore stops on \0xff
- Reply-to: mki at maconomy dot dk
>Number: 6360
>Category: libstdc++
>Synopsis: Wrong workaround in char_traits.h - ignore stops on \0xff
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Apr 18 08:06:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Mads Kiilerich
>Release: 3.0.4
>Organization:
>Environment:
Seen on RedHat linux 6.2 - and on Solaris 2.7
>Description:
The default delimiter for Istream::ignore is EOF (-1).
Several places in include/g++-v3/bits/istream.tcc the following is found:
const int_type __idelim = traits_type::to_int_type(__delim);
calling the method in gcc/include/g++-v3/bits/char_traits.h:184 :
// To keep both the byte 0xff and the eof symbol 0xffffffff
// from ending up as 0xffffffff.
static int_type
to_int_type(const char_type& __c)
{ return static_cast<int_type>(static_cast<unsigned char>(__c)); }
- but then __idelim is set to 255, causing Istream::ignore to stop ignoring first time it meets a char value of 255.
In this case the delimiter should be -1, so that ignorance only stops when a real negative unsigned char is found - and that hardly happens...
>How-To-Repeat:
The following testcase is expected to do as it does when compiled with KAI:
[mk@linux-tools IstreamIgnore]$ ./IstreamIgnore.KCC
1st char is: a
Skipping 8 chars (i.e. until after the digits)...
The rest of the stream contains: 'abcd'
But using gcc 3.0.4 we get:
[mk@linux-tools IstreamIgnore]$ ./IstreamIgnore.gcc
1st char is: a
Skipping 8 chars (i.e. until after the digits)...
The rest of the stream contains: '1234abcd'
>Fix:
Idunno. But the current workaround does not seem good...
>Release-Note:
>Audit-Trail:
>Unformatted: