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
Fix somes warning when compiling with Visual Studio 2019 on x64 target #8125
Fix somes warning when compiling with Visual Studio 2019 on x64 target #8125
Conversation
These warning fixes are simple.
|
@coryan @acozzette regards,gilles |
src/google/protobuf/parse_context.h
Outdated
@@ -208,7 +208,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { | |||
bool DoneWithCheck(const char** ptr, int d) { | |||
GOOGLE_DCHECK(*ptr); | |||
if (PROTOBUF_PREDICT_TRUE(*ptr < limit_end_)) return false; | |||
int overrun = *ptr - buffer_end_; | |||
size_t overrun = *ptr - buffer_end_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this has to be a signed type because overrun
can be negative. Maybe std::ptrdiff_t
would be the right type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider: auto overrun = *ptr - buffer_end_;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finally, I made a new commit with
int overrun = static_cast<int>(*ptr - buffer_end_);
overrun is used for compare with limit_ (which is int) and as first argument of DoneFallback (which expect int).
In visual studio 2019 x64 target, size_t are 64 bits and int are 32 bits
Thanks, @gvollant. |
In visual studio 2019 x64 target, pointer size and size_t are 64 bits and int are 32 bits
This commit uses size_t for buffer size