[llvm-bugs] [Bug 50717] New: std::ranges::size incorrectly uses perfect forwarding
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jun 15 05:02:04 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50717
Bug ID: 50717
Summary: std::ranges::size incorrectly uses perfect forwarding
Product: libc++
Version: 12.0
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: zilla at kayari.org
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
test/std/ranges/range.access/range.prim/size.pass.cpp has this check:
assert(std::ranges::size(MoveOnlySizeFunction()) == 42);
which relies on this function being called with an rvalue:
friend constexpr size_t size(MoveOnlySizeFunction) { return 42; }
However, the relevant part of the standard says an lvalue should be used:
"then ranges::size(E) is expression-equivalent to decay-copy(size(t))"
where 't' is an lvalue, i.e. it should not be forwarded.
As a result, the test fails for libstdc++ trunk (since I fixed the same bug
earlier this month).
The spec was changed by https://wg21.link/p2091r0 to use lvalues everywhere
except ranges::cdata.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210615/4959508f/attachment.html>
More information about the llvm-bugs
mailing list