This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Make std::basic_istream::get 0-terminate input array in case of error.
ClosedPublic

Authored by vsapsai on Nov 30 2017, 2:19 PM.

Details

Summary

It covers the cases when the sentry object returns false and when an exception
was thrown. Corresponding standard paragraph is C++14 [istream.unformatted]p9:

[...] In any case, if n is greater than zero it then stores a null
character into the next successive location of the array.

rdar://problem/35566567

Diff Detail

Repository
rL LLVM

Event Timeline

vsapsai created this revision.Nov 30 2017, 2:19 PM

A couple of nits, but other than that, looks fine.

libcxx/include/istream
970 ↗(On Diff #125019)

I'm not a big fan of "putting braces around single statement blocks", and (see line 963) that doesn't match the rest of libcxx.

libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
16 ↗(On Diff #125019)

Does this need to XFAIL for clang < 6 as well?

mclow.lists accepted this revision.Jan 11 2018, 7:22 AM

Please make the formatting match the rest of the file.

libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
16 ↗(On Diff #125019)

I don't think that it does. Never mind this.

This revision is now accepted and ready to land.Jan 11 2018, 7:22 AM
vsapsai updated this revision to Diff 129525.Jan 11 2018, 2:25 PM
  • Remove curly braces for single-statement ifs.
vsapsai marked an inline comment as done.Jan 11 2018, 2:33 PM

Thanks for the review.

libcxx/include/istream
970 ↗(On Diff #125019)

Thanks for pointing this out. I was making sure to follow the style of opening curly brace on its own line and missed that you don't need curly braces in this case.

libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
16 ↗(On Diff #125019)

In theory, it should be done for earlier versions too. But in practice that's not required.

This revision was automatically updated to reflect the committed changes.