public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/11705] New: Bad interaction between cin and wcin after sync_with_stdio(false)
@ 2003-07-29 10:12 peturr02 at ru dot is
  2003-07-29 10:14 ` [Bug libstdc++/11705] " peturr02 at ru dot is
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: peturr02 at ru dot is @ 2003-07-29 10:12 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11705

           Summary: Bad interaction between cin and wcin after
                    sync_with_stdio(false)
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: peturr02 at ru dot is
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

If sync_with_stdio(false) is called, it is possible to mix calls to
cin and wcin. This violates 27.3:

  Mixing operations on corresponding wide- and narrow-character streams
  follows the same semantics as mixing such operations on FILEs, as
  specified in Amendment 1 of the ISO C standard.

I don't have Amendment 1, but on my system (glibc-2.3) it is not
possible to mix wide and narrow input operations on the same FILE.

It also violates 22.2.1.5.2:

  Preconditions: [...] state initialized, if at the beginning of a
  sequence, or else equal to the result of converting the preceding
  characters in the sequence.

wcin uses codecvt, but the bytes read through cin never pass through
wcin, so state can never be the result of converting those bytes, and
any attempt to convert later bytes is a precondition violation
(undefined behaviour).

Even for stateless conversions, cin may not leave the file pointer
at a character boundary; any attempt to convert a sequence of bytes
that doesn't begin at a character boundary will either fail or give
meaningless results.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-12-05 23:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-29 10:12 [Bug libstdc++/11705] New: Bad interaction between cin and wcin after sync_with_stdio(false) peturr02 at ru dot is
2003-07-29 10:14 ` [Bug libstdc++/11705] " peturr02 at ru dot is
2003-08-04  2:24 ` pinskia at physics dot uc dot edu
2003-08-23  1:01 ` dhazeghi at yahoo dot com
2003-12-05 23:44 ` bkoz at gcc dot gnu dot org

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).