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

Issue with iota and adapters with clang #82

Closed
anders-sjogren opened this issue Dec 11, 2014 · 1 comment
Closed

Issue with iota and adapters with clang #82

anders-sjogren opened this issue Dec 11, 2014 · 1 comment

Comments

@anders-sjogren
Copy link
Contributor

Consider the following code:

auto odd_ints = ranges::view::ints(1)|ranges::view::remove_if([](auto&& x){return x%2==0;});

It compiles on gcc 4.9.1 (from macports "gcc49 @4.9.1_1"). Clang pre 3.6 (from macports clang-3.6 @3.6-r222672_0+analyzer+arm_runtime+assertions) does however fail with the error:

src/main.cpp:114:86: error: invalid operands to binary expression ('ranges::v3::iota_view<int, void>' and 'int')
  auto odd_ints = ranges::view::ints(1)|ranges::view::remove_if([](auto&& x){return x%2==0;});
                                                                                    ~^~

Thus, x seems to be of type ranges::v3::iota_view<int, void> and not int (or const int&).
Changing the argument of the filter predicate to intmakes it compile:

  auto odd_ints = ranges::view::ints(1)|ranges::view::remove_if([](int x){return x%2==0;});

While interestingly, trying to explicitly convert x to int does not:

src/main.cpp:114:86: error: no matching conversion for C-style cast from 'ranges::v3::iota_view<int, void>' to 'int'

  auto odd_ints = ranges::view::ints(1)|ranges::view::remove_if([](auto&& x){return ((int)x)%2==0;});
                                                                                     ^~~~~~

Is this a clang-bug which should be reported(?), or is it a ranges-bug which exploits non-standard behavior of gcc?

@ericniebler
Copy link
Owner

It works for me with a recently-build-from-trunk clang.I'm guessing this is a clang bug that was fixed recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants