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

wrong result when using std::view::zip #40

Closed
yuanzihao-1991 opened this issue Nov 28, 2024 · 5 comments
Closed

wrong result when using std::view::zip #40

yuanzihao-1991 opened this issue Nov 28, 2024 · 5 comments
Assignees
Labels

Comments

@yuanzihao-1991
Copy link

yuanzihao-1991 commented Nov 28, 2024

Here is my code compiled with option -std=c++23, gcc 14.2:

#include "timsort.hpp"
#include <array>
#include <iostream>
#include <tuple>
#include <vector>

int main() {
  auto x = std::vector{4, 2, 3, 1};
  auto y = std::array{'A', 'C', 'B', 'D'};
  auto xy = std::views::zip(x, y);

  gfx::timsort(xy, {},
   [](const std::tuple<int &, char &> &a) {
    return std::get<0>(a);
  });

  for (std::tuple<int &, char &> elem : xy) {
    std::cout << std::get<0>(elem) << ' ' << std::get<1>(elem) << ' ' << '\n';
  }
}

Expected result is:

1 D 
2 C 
3 B 
4 A

However, I got

4 A 
2 C 
4 A 
4 A 
@Morwenn
Copy link
Member

Morwenn commented Nov 28, 2024

Hi, and thanks for the bug report!

I confirm the issue, and it looks like a bug since std::ranges::sort works very well there. I am going to investigate the issue.

@Morwenn Morwenn added the bug label Nov 28, 2024
@Morwenn Morwenn self-assigned this Nov 28, 2024
Morwenn added a commit that referenced this issue Nov 28, 2024
Morwenn added a commit that referenced this issue Nov 28, 2024
Morwenn added a commit that referenced this issue Nov 28, 2024
@Morwenn
Copy link
Member

Morwenn commented Nov 28, 2024

It turns out that I did not handle proxy iterators correctly. I pushed a new commit to branch 3.x.y which fixes the issue.

The pipeline is partly broken because the CI jobs were meant to target C++20 and I will have some additional work to do in that area, but I ran tests locally with GCC 14, and the issues seems fixed.

@yuanzihao-1991
Copy link
Author

It turns out that I did not handle proxy iterators correctly. I pushed a new commit to branch 3.x.y which fixes the issue.

The pipeline is partly broken because the CI jobs were meant to target C++20 and I will have some additional work to do in that area, but I ran tests locally with GCC 14, and the issues seems fixed.

Great! Thanks a lot for your quick response and efforts!

@Morwenn
Copy link
Member

Morwenn commented Dec 1, 2024

No problem!

Do you confirm that the issue is fixed on your side? If so, we can close that ticket.

@yuanzihao-1991
Copy link
Author

No problem!

Do you confirm that the issue is fixed on your side? If so, we can close that ticket.

Confirmed. Perfect! Thank you!

@Morwenn Morwenn closed this as completed Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants