Skip to content

Invalid iterators for empty std::ranges::join_view #93180

@StailGot

Description

@StailGot
#include <iostream>
#include <ranges>
#include <vector>
 
int main()
{
  const std::array<std::vector<int>, 2> v;
  const auto jv = std::ranges::join_view(v);
  
  if (auto it = std::ranges::find(jv, 5); it != jv.end())
    std::cout << std::distance(jv.begin(), it); // should not enter here

   std::cout << 42 << std::endl;
}

// clang++-18 main.cpp --std=c++20 -stdlib=libc++ && ./a.out - # hangs or crash
// clang++-18 main.cpp --std=c++20 -stdlib=libstdc++ && ./a.out - # Ok with libstdc++ or gcc

Code compiled with latest clang 18.1.6 and libc++ hangs or crash with Segmentation fault.

https://godbolt.org/z/hxzP7axWj

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.rangesIssues related to `<ranges>`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions