ldionne accepted this revision.
ldionne added inline comments.
This revision is now accepted and ready to land.


================
Comment at: include/istream:601
+    streamsize __n = __is.width();
+    if (__n <= 0)
+        __n = numeric_limits<streamsize>::max() / sizeof(_CharT) - 1;
----------------
Should this instead be `if (__n == 0)`? Can `width()` ever return a negative 
number? cppreference says this about `streamsize`:

> Except in the constructors of `std::strstreambuf`, negative values of 
> `std::streamsize` are never used.

I couldn't find a matching statement in the standard, however there's this 
footnote in `30.5.2`:

> `streamsize` is used in most places where ISO C would use `size_t`. Most of 
> the uses of `streamsize` could use `size_t`, except for the `strstreambuf` 
> constructors, which require negative values. It should probably be the signed 
> type corresponding to `size_t` (which is what Posix.2 calls `ssize_t`).

This does not clearly say that negative values are never used, but it does 
suggest it. Maybe it's safer to still use `__n <= 0`.



Repository:
  rCXX libc++

https://reviews.llvm.org/D51268



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to