Issue 56417
Summary Clang fails to compile ranges example from cppreference using libstdc++
Labels c++20, rejects-valid, libstdc++
Assignees
Reporter junaire
    The example below is taken from: https://en.cppreference.com/w/cpp/ranges
```
#include <ranges>
#include <iostream>
 
int main()
{
    auto const ints = {0,1,2,3,4,5};
    auto even = [](int i) { return 0 == i % 2; };
    auto square = [](int i) { return i * i; };
 
    // "pipe" syntax of composing the views:
    for (int i : ints | std::[views::filter](http://en.cppreference.com/w/cpp/ranges/filter_view)(even) | std::[views::transform](http://en.cppreference.com/w/cpp/ranges/transform_view)(square)) {
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << i << ' ';
    }
 
    [std::cout](http://en.cppreference.com/w/cpp/io/cout) << '\n';
 
    // a traditional "functional" composing syntax:
    for (int i : std::[views::transform](http://en.cppreference.com/w/cpp/ranges/transform_view)(std::[views::filter](http://en.cppreference.com/w/cpp/ranges/filter_view)(ints, even), square)) {
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << i << ' ';
    }
}
```

GCC and MSVC both accept it, and Clang can compile it with `-stdlib=libc++`, but fails with `libstdc++`. (https://godbolt.org/z/erv7TbdsG)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to