[all-commits] [llvm/llvm-project] 54daf6: [libc++] Fixes istream::sync. (#76467)

Mark de Wever via All-commits all-commits at lists.llvm.org
Sun Feb 18 08:21:01 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 54daf6af57fb15d7a51e3f4bb889199fd1453bee
      https://github.com/llvm/llvm-project/commit/54daf6af57fb15d7a51e3f4bb889199fd1453bee
  Author: Mark de Wever <koraq at xs4all.nl>
  Date:   2024-02-18 (Sun, 18 Feb 2024)

  Changed paths:
    M libcxx/include/istream
    M libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp

  Log Message:
  -----------
  [libc++] Fixes istream::sync. (#76467)

This fixes two issues.

The return value
----------------

Based on the wording

[istream.unformatted]/37
Effects: Behaves as an unformatted input function (as described above),
  except that it does not count the number of characters extracted and
  does not affect the value returned by subsequent calls to gcount().
  After constructing a sentry object, if rdbuf() is a null pointer,
  returns -1.

[istream.unformatted]/1
... It then creates an object of class sentry with the default argument
noskipws (second) argument true. If the sentry object returns true, when
converted to a value of type bool, the function endeavors to obtain the
  requested input. ...

It could be argued the current behaviour is correct, however
constructing a istream rdbuf() == nullptr creates a sentry that returns
false; its state is always bad in this case.

As mentioned in the bug report, after this change the 3 major
implementations behave the same.

The setting of the state
------------------------

When pubsync returned -1 it updated the local __state variable and
returned. This early return caused the state up the istream not to be
updated to the new state.

Fixes: https://github.com/llvm/llvm-project/issues/51497
Fixes: https://github.com/llvm/llvm-project/issues/51499

---------

Co-authored-by: Louis Dionne <ldionne.2 at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list