Open gordondow opened 2 years ago
In spite of the try/catch clause, the following program terminates abnormally with an uncaught exception:
#include <exception> #include <iostream> #include <sstream> #include <range/v3/algorithm/for_each.hpp> #include <range/v3/view/chunk.hpp> struct my_input_container { std::istream_iterator<char> begin() { throw std::runtime_error(""); } std::istream_iterator<char> end() { return {}; } }; int main(int argc, const char * argv[]) { try { my_input_container zzz; auto rng = zzz | ranges::views::chunk(2); ranges::for_each(rng, [](auto&& rng){}); } catch(...) { std::cout << "exception occurred."; } }
The crash (termination with uncaught exception) occurs because of this code in view/chunk.hpp:
view/chunk.hpp
constexpr outer_cursor begin_cursor() noexcept { it_cache_ = ranges::begin(base_); return outer_cursor{this}; }
The call to ranges::begin() (in this case) throws an exception, but begin_cursor is marked noexcept, so the program terminates. I think this should be:
ranges::begin()
begin_cursor
noexcept
constexpr outer_cursor begin_cursor() noexcept(noexcept(ranges::begin(base_))) { it_cache_ = ranges::begin(base_); return outer_cursor{this}; }
In spite of the try/catch clause, the following program terminates abnormally with an uncaught exception:
The crash (termination with uncaught exception) occurs because of this code in
view/chunk.hpp
:The call to
ranges::begin()
(in this case) throws an exception, butbegin_cursor
is markednoexcept
, so the program terminates. I think this should be: