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

Fix all sign-conversion warnings reported by gcc compiler #625

Closed
mohammedRafeeque opened this issue Jun 11, 2024 · 4 comments
Closed

Fix all sign-conversion warnings reported by gcc compiler #625

mohammedRafeeque opened this issue Jun 11, 2024 · 4 comments
Assignees
Labels
bug Something isn't working c++ C++ language generator
Milestone

Comments

@mohammedRafeeque
Copy link

Zserio version and language
Zserio: latest from master
Commit date: 6 days ago (6/4/2024 7:12:28 PM)
Commit hash: b8cc6c0

Language: C++

Describe the bug

Followup of old issue #579
Getting the bellow errors related to -Wconversion.

  1. zserio_runtime/zserio/FloatUtil.cpp:68:33: error: conversion to 'unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion]
    exponent32 = exponent16 - FLOAT16_EXPONENT_BIAS + FLOAT32_EXPONENT_BIAS;
    ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
    cc1plus: all warnings being treated as errors
  2. zserio_runtime/zserio/BitStreamWriter.cpp:659:90: error: conversion to 'std::array<long unsigned int, 8>::size_type' {aka 'long unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
    const uint8_t add = static_cast<uint8_t>((value >> shiftBits) & bitMasks[numBits - 1]);
    ~~~~~~~~^~~
    cc1plus: all warnings being treated as errors

How to reproduce
Steps to reproduce the behavior:
used gcc version
gcc --version
gcc (Ubuntu 8.4.0-3ubuntu2) 8.4.0

Expected behavior
No compilation warnings

@mikir Please check

@mohammedRafeeque mohammedRafeeque added the bug Something isn't working label Jun 11, 2024
@mikir mikir added the c++ C++ language generator label Jun 11, 2024
@mikir mikir added this to the 2.15 milestone Jun 11, 2024
@mikir
Copy link
Contributor

mikir commented Jun 11, 2024

It seems to me that the reported warnings are related to the -Wsign-conversion option and not to -Wconversion option. Is it correct? Does it mean that you request to enable another -Wsign-conversion gcc option as well and investigate/fix all possible reported warnings?

@mohammedRafeeque
Copy link
Author

mohammedRafeeque commented Jun 12, 2024

Yes, you are right, reported warnings are related to the -Wsign-conversion option.
Yes, for direct integration of Zserio runtime lib without any manual adaptations,request to enable another -Wsign-conversion gcc option as well.
For zserio runtime lib only two warning instance only observed.
@Roland-Homeier : FYI

@mikir mikir changed the title Enable conversion warnings for gcc compiler, two warnings reported Fix all sign-conversion warnings reported by gcc compiler Jun 12, 2024
@mikir
Copy link
Contributor

mikir commented Jun 12, 2024

Yes, you are right, reported warnings are related to the -Wsign-conversion option. Yes, for direct integration of Zserio runtime lib without any manual adaptations,request to enable another -Wsign-conversion gcc option as well. For zserio runtime lib only two warning instance only observed.

OK, thanks for the clarification. We will do it within the current milestone.

@mikir mikir self-assigned this Jun 18, 2024
@mikir
Copy link
Contributor

mikir commented Jun 19, 2024

Please note that there is a bug till gcc version 9.3.0 which caused sign-conversion warning even if it is fixed (for more info please see the bug report).

@mikir mikir closed this as completed Jun 19, 2024
@mikir mikir modified the milestones: 2.15, 2.14.1 Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working c++ C++ language generator
Projects
None yet
Development

No branches or pull requests

2 participants