This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/11705] New: Bad interaction between cin and wcin after sync_with_stdio(false)


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]