https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120367
Bug ID: 120367
Summary: C++23 ranges::transform | ranges::to exception
catching (segfault)
Product: gcc
Version: 15.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: lexa.nf at yandex dot ru
Target Milestone: ---
Hello!
My colleague ran into the problem that GCC 15.1 doesn't handle exceptions
properly with std::ranges::transform | std::ranges::to. Program just shuts down
with SIGSEGV, but GCC 14.2 handles this as planned.
System: Arch Linux, x64
Test case:
#include <string>
#include <vector>
#include <ranges>
#include <exception>
#include <iostream>
auto main() -> int
{
try
{
auto vec = std::vector<std::string>{ "1", "2", "3", "4", "5" };
auto rng = vec
| std::views::transform([](auto elt) { throw std::runtime_error{ "error"
}; return elt; })
| std::ranges::to<std::vector>();
}
catch (const std::runtime_error& err)
{
std::cerr << "Oops: " << err.what() << std::endl;
}
}
Compile options: -std=c++23
No compile errors and warnings.
Debug options shows nothing: -std=c++23 -Wall -Wextra -fno-strict-aliasing
-fwrapv -D_GLIBCXX_ASSERTIONS -fno-aggressive-loop-optimizations
Reproduce online: https://godbolt.org/z/GfxYMMWa3
Correct behaviour online: https://godbolt.org/z/z6fonGjPc