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

Clang can't compile libstdc++ ranges #46091

Closed
llvmbot opened this issue Jul 16, 2020 · 10 comments
Closed

Clang can't compile libstdc++ ranges #46091

llvmbot opened this issue Jul 16, 2020 · 10 comments
Labels
bugzilla Issues migrated from bugzilla c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts duplicate Resolved as duplicate

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 16, 2020

Bugzilla Link 46746
Version trunk
OS Linux
Attachments Preprocessed example that reproduces the error.
Reporter LLVM Bugzilla Contributor
CC @avikivity,@JohelEGP,@mmatrosov,@zygoloid,@HighCommander4

Extended Description

GCC 10.1.0 came with libstdc++ that has <ranges> implemented. Also clang 10 supports concepts. I wanted to use clang to compile a simple snippet that relies on ranges, but clang encountered some errors that just don't happen with gcc.

#include <ranges>

int main(void)
{
 char c[3] = {'a', 'b', 'v'};
 std::ranges::subrange sub(c);
}

The preprocessed file can be found here: https://godbolt.org/z/7hfbq5
I've also made an attachment with the same preprocessed file compressed.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 16, 2020

Hm, I've just realized that gcc also can't compile the code if clang is used to preprocess it first.

@HighCommander4
Copy link
Collaborator

Hm, I've just realized that gcc also can't compile the code if clang is used
to preprocess it first.

I think that's expected. Standard library headers contain preprocessor branches conditioned on things like __has_builtin(). Since gcc and clang don't support the exact same set of builtins, preprocessing with one can easily result in code that's not compilable with the other.

@avikivity
Copy link
Mannequin

avikivity mannequin commented Sep 19, 2020

Here's another example that fails with clang:

======= begin example =============
#include

void foo() {
std::ranges::iota_view iota(2, 10);
iota.begin();
}
======== end example ==============

clang complains that iota_view doesn't have a begin(), which it does.

@avikivity
Copy link
Mannequin

avikivity mannequin commented Sep 19, 2020

I think this is a libstdc++ bug. Details here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97120.

@mmatrosov
Copy link

Another example:

#include
#include
#include

std::map<int, int> map;

int main() {
map[0] = 10;
map[1] = 20;
for (int key : std::ranges::views::keys(map)) {
std::cout << key << ' ';
}
}

https://godbolt.org/z/4GbrG3a5W

@mmatrosov
Copy link

I blieve this is due to this bug: llvm/llvm-bugzilla-archive#50864

@0x8000-0000
Copy link
Member

mentioned in issue llvm/llvm-bugzilla-archive#50328

@mmatrosov
Copy link

mentioned in issue llvm/llvm-bugzilla-archive#50864

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@Quuxplusone Quuxplusone added the concepts C++20 concepts label Jan 16, 2022
@royjacobson
Copy link
Contributor

Confirmed to work after https://reviews.llvm.org/D126907, so this was also a duplicate of #44178. Closing.

@royjacobson royjacobson closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2022
@royjacobson royjacobson added the duplicate Resolved as duplicate label 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 Author

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
bugzilla Issues migrated from bugzilla 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

7 participants