[Bug libstdc++/102181] std::advance and std::views::iota<std::int64_t> don't work
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Sep 2 22:13:03 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102181
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Raffael Casagrande from comment #3)
> MSVC compiles the snippet without problems...
It looks like they do not correctly implement iota_view. This C++20 proposal,
specifically:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1522r1.pdf
This program fails with MSVC:
#include <ranges>
int main() {
using type = uint64_t; // using type = int works!
auto v = std::views::iota(0ull, ~0ull);
auto b = v.end() - v.begin();
static_assert(!std::same_as<decltype(b), int64_t>);
}
It is required to compile. You cannot use int64_t to represent the difference
type of an iota_view with that many elements.
I think GCC is correct according to the standard.
More information about the Gcc-bugs
mailing list