public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/101091] New: std::views::take and std::views::drop are overconstrained
@ 2021-06-16 10:45 j.galecki11 at gmail dot com
2021-06-16 10:54 ` [Bug libstdc++/101091] " j.galecki11 at gmail dot com
2021-06-16 13:20 ` ppalka at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: j.galecki11 at gmail dot com @ 2021-06-16 10:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101091
Bug ID: 101091
Summary: std::views::take and std::views::drop are
overconstrained
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: j.galecki11 at gmail dot com
Target Milestone: ---
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/101091] std::views::take and std::views::drop are overconstrained
2021-06-16 10:45 [Bug libstdc++/101091] New: std::views::take and std::views::drop are overconstrained j.galecki11 at gmail dot com
@ 2021-06-16 10:54 ` j.galecki11 at gmail dot com
2021-06-16 13:20 ` ppalka at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: j.galecki11 at gmail dot com @ 2021-06-16 10:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101091
--- Comment #1 from Jakub Gałecki <j.galecki11 at gmail dot com> ---
Consider the following example: https://godbolt.org/z/YYzqWaM9G
#include <algorithm>
#include <ranges>
#include <vector>
void copy_drop_n1(const std::vector<double>& src, std::vector<double>& dest,
std::size_t n) { // size_t - narrowing conversion
std::ranges::copy(src | std::views::drop(n), begin(dest) + n);
}
void copy_drop_n2(const std::vector<double>& src, std::vector<double>& dest,
std::ptrdiff_t n) { // ptrdiff_t
std::ranges::copy(src | std::views::drop(n), begin(dest) + n);
}
As per the standard [range.take.overview]:
The name views::take denotes a range adaptor object ([range.adaptor.object]).
Let E and F be expressions, let T be remove_cvref_t<decltype((E))>, and let D
be range_difference_t<decltype((E))>. If decltype((F)) does not model
convertible_to<D>, views::take(E, F) is ill-formed. Otherwise, the
expression views::take(E, F) is expression-equivalent to [...]
The example above should therefore compile for size_t as well as ptrdiff_t,
since size_t is convertible to ptrdiff_t. This is a regression from libstdc++
version 10.x, where both functions compile.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/101091] std::views::take and std::views::drop are overconstrained
2021-06-16 10:45 [Bug libstdc++/101091] New: std::views::take and std::views::drop are overconstrained j.galecki11 at gmail dot com
2021-06-16 10:54 ` [Bug libstdc++/101091] " j.galecki11 at gmail dot com
@ 2021-06-16 13:20 ` ppalka at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-16 13:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101091
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
CC| |ppalka at gcc dot gnu.org
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Thanks for the bug report. This regression is already fixed for GCC 11.2 and
12, see PR100558.
*** This bug has been marked as a duplicate of bug 100558 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-16 13:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 10:45 [Bug libstdc++/101091] New: std::views::take and std::views::drop are overconstrained j.galecki11 at gmail dot com
2021-06-16 10:54 ` [Bug libstdc++/101091] " j.galecki11 at gmail dot com
2021-06-16 13:20 ` ppalka at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).