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

MSVC warning C4365: signed/unsigned mismatch in cxx.h iterator operator- overload #1227

Closed
wravery opened this issue Jun 15, 2023 · 0 comments

Comments

@wravery
Copy link
Contributor

wravery commented Jun 15, 2023

This is very similar to #1225, but I missed this one in cxx.h because it happened later in my own code once building the cxx crate dependency was unblocked:

template <typename T>
typename Slice<T>::iterator::difference_type
Slice<T>::iterator::operator-(const iterator &other) const noexcept {
  auto diff = std::distance(static_cast<char *>(other.pos),
                            static_cast<char *>(this->pos));
  return diff / this->stride;
}

It's reporting the same signed/unsigned warning (treated as an error in my case), but this time the issue is that this->stride is a size_t and diff and the typename Slice<T>::iterator::difference_type return type are both signed ptrdiff_t.

I should have a fix, but I want to make sure there aren't any more of these lurking in my code before I make another PR.

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

1 participant