This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fix LWG3589 "The const lvalue reference overload of get for subrange..."
ClosedPublic

Authored by Quuxplusone on Jan 22 2022, 11:35 AM.

Diff Detail

Event Timeline

Quuxplusone requested review of this revision.Jan 22 2022, 11:35 AM
Quuxplusone created this revision.
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald TranscriptJan 22 2022, 11:35 AM
Mordante added inline comments.Jan 23 2022, 5:01 AM
libcxx/include/__ranges/subrange.h
230

I don't mind (_Index == 1), but the current code doesn't match the LWG issue.

libcxx/test/std/ranges/range.utility/range.subrange/get.pass.cpp
49

Use after move of r, likewise in the two blocks below.

Quuxplusone marked an inline comment as done.Jan 24 2022, 12:13 PM
Quuxplusone added inline comments.
libcxx/include/__ranges/subrange.h
230

I'll throw parens around the whole expression, because now I'm paranoid some compiler won't like top-level requires A || B; but I'll keep the parens on the individual terms too, for clarity.

libcxx/test/std/ranges/range.utility/range.subrange/get.pass.cpp
49

Since this copies the sentinel even when r is an rvalue, I think it's OK — might even be a test-coverage benefit!
Or I guess rather: Since std::get<0>(std::move(r)) isn't supposed to touch the sentinel member of r, (etc.)

Quuxplusone marked an inline comment as done.

Tweak parens (I went with @Mordante's version after all), re-poke CI just for the heck of it.

Re-poke CI, since "patch application failed" last time.

Mark two ranges tests as UNSUPPORTED: libcpp-no-unsupported-ranges to fix https://buildkite.com/llvm-project/libcxx-ci/builds/8211
(D118507 is tangentially related.)

My last diff misspelled libcpp-has-no-incomplete-ranges, and anyway I just pushed that fix, so remove it from here again. Poke CI.

Mordante accepted this revision as: Mordante.Jan 31 2022, 11:10 AM

LGTM with one minor issue.

libcxx/test/std/ranges/range.utility/range.subrange/get.pass.cpp
49

Please add a comment why this is safe

Quuxplusone accepted this revision.Feb 1 2022, 12:07 PM
This revision is now accepted and ready to land.Feb 1 2022, 12:07 PM