Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++/clang] std::ranges::views::take does not work with | operator #55673

Closed
mattreecebentley opened this issue May 24, 2022 · 6 comments
Closed
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts duplicate Resolved as duplicate

Comments

@mattreecebentley
Copy link

mattreecebentley commented May 24, 2022

The following code in C++20:

#include <vector>
#include <ranges>


int main()
{
	std::vector<int> i_vec({1, 2, 3});
	auto rng = i_vec | std::ranges::views::take(2);
	return 0;
}

Produces the following error in Clang 14.00:

<source>:8:19: error: invalid operands to binary expression ('std::vector<int>' and '_Partial<std::ranges::views::_Take, decay_t<int>>' (aka '_Partial<std::ranges::views::_Take, int>'))
        auto rng = i_vec | std::ranges::views::take(2);

Godbolt: https://godbolt.org/z/c35r4Pa1h

The code as far as I can tell, is valid and works in GCC11 and MSVC 2022.
Unsure whether this is a libc++ or clang bug.

@EugeneZelenko EugeneZelenko added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. c++20 and removed new issue labels May 24, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented May 24, 2022

@llvm/issue-subscribers-c-20

@cpplearner
Copy link
Contributor

cpplearner commented May 24, 2022

Well, the godbolt link uses libstdc++, so it's certainly not a libc++ bug.

I believe that libstdc++'s <ranges> does not work with clang at all, because clang's support for concepts is incomplete.

@EugeneZelenko EugeneZelenko removed the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label May 24, 2022
@mattreecebentley
Copy link
Author

mattreecebentley commented May 24, 2022 via email

@erichkeane
Copy link
Collaborator

Is this a duplicate of the 'deferred concepts' feature? A lot of the ranges::views stuff ends up having that problem. Patch is in progress/1 bug left (AFAIK) here: https://reviews.llvm.org/D126907#3574083

I note that the preprocessed version of this ends up crashing in my patch in std::vector, but it is hopefully the same issue that I'm already looking into.

@royjacobson
Copy link
Contributor

Works after https://reviews.llvm.org/D126907, so this was a duplicate of #44178 indeed.

@royjacobson royjacobson closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2022
@royjacobson royjacobson added duplicate Resolved as duplicate concepts C++20 concepts labels Sep 23, 2022
@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Sep 23, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 23, 2022

@llvm/issue-subscribers-clang-frontend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts duplicate Resolved as duplicate
Projects
Status: Done
Development

No branches or pull requests

6 participants