public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: mki@maconomy.dk
To: gcc-gnats@gcc.gnu.org
Subject: libstdc++/6360: Wrong workaround in char_traits.h - ignore stops on \0xff
Date: Thu, 18 Apr 2002 08:06:00 -0000	[thread overview]
Message-ID: <20020418145756.9452.qmail@sources.redhat.com> (raw)


>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:


             reply	other threads:[~2002-04-18 15:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-18  8:06 mki [this message]
2002-04-18  8:26 Mads
2002-04-19 12:28 bkoz
2002-04-22 13:31 bkoz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020418145756.9452.qmail@sources.redhat.com \
    --to=mki@maconomy.dk \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).