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

Comparison of integer expressions of different signedness #11

Closed
sounddroid opened this issue Sep 30, 2019 · 1 comment · Fixed by #16
Closed

Comparison of integer expressions of different signedness #11

sounddroid opened this issue Sep 30, 2019 · 1 comment · Fixed by #16

Comments

@sounddroid
Copy link

Hello! Using gcc 9.1.0, I'm getting a few compiler warnings:

In reader.hpp:

Line 220:
if (frameOffset < 0 && dataChunkOffset < -frameOffset) {
*warning: comparison of integer expressions of different signedness: 'uint64_t' {aka 'long unsigned int'} and 'int64_t' {aka 'long int'} [-Wsign-compare]

Line 225:
if (fileStream_.tellg() < chunkPosition) {
*warning: comparison of integer expressions of different signedness: 'std::streamoff' {aka 'long int'} and 'uint64_t' {aka 'long unsigned int'} [-Wsign-compare]

Line 227:
} else if (fileStream_.tellg() > chunkPosition + dataChunk()->size()) {
*comparison of integer expressions of different signedness: 'std::streamoff' {aka 'long int'} and 'uint64_t' {aka 'long unsigned int'} [-Wsign-compare]

Any chance that this can get looked at and addressed safely?

@bluetarpmedia
Copy link

This should fix them:

if (frameOffset < 0 && dataChunkOffset < static_cast<uint64_t>(-frameOffset)) {

and

const auto fileStreamPos = fileStream_.tellg();
if (fileStreamPos < 0)
  throw std::runtime_error("fileStream::tellg failed");
if (static_cast<uint64_t>(fileStreamPos) < chunkPosition) {
  fileStream_.seekg(chunkPosition);
} else if (static_cast<uint64_t>(fileStreamPos) > chunkPosition + dataChunk()->size()) {
  fileStream_.seekg(chunkPosition + dataChunk()->size());
}

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

Successfully merging a pull request may close this issue.

2 participants