https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119516

            Bug ID: 119516
           Summary: SIGKILL when -O2
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following code produces:

Killed - processing time exceeded
Program terminated with signal: SIGKILL
Compiler returned: 143

when using -O2.

#include <vector>
#include <print>
#include <ranges>
#include <string>
#include <iterator>
#include <iostream>

auto main(int,char**) -> int
{
    const std::vector<std::string> input = {"World 0", "World 1", "World 2",
"World 3", "World 4", "World 5", "World 6", "World 7", "World 8", "Earth"};

    auto output = input
    | std::views::take_while([](const auto& n) {std::println("{:10} called:
{}","take_while", n); return n.at(n.size()-1) != '5'; })
    | std::views::filter   ([](const auto& n) {std::println("{:10} called:
{}","filter", n); return n.at(n.size()-1) != '2'; })
    | std::views::transform([](const auto& n) {std::println("{:10} called:
{}","transform", n);return std::string("Hello ")+n+" "; });

   
std::ranges::copy(output,std::ostream_iterator<std::string>(std::cout,"\n"));
}


Not sure what's going on.

https://godbolt.org/z/6nc7vj6aW

Reply via email to