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 -Wsign-compare failures on 32 bit architecture #3896

Closed
aditishri18 opened this issue Mar 20, 2023 · 6 comments · Fixed by #4061
Closed

Fix -Wsign-compare failures on 32 bit architecture #3896

aditishri18 opened this issue Mar 20, 2023 · 6 comments · Fixed by #4061

Comments

@aditishri18
Copy link
Contributor

Problem:

-Wsign-compare check was enabled to warn when a comparison between signed and unsigned values produce an incorrect result. This PR caused failures on 32bit architecture. To fix the problem, the check was disabled and added as a debug build here.

Solution:

To ensure that the errors listed in PR are fixed, a 32bit build in the CI is required for testing. This will ensure any such code breakage on multiple architectures.

@jhgit
Copy link

jhgit commented Mar 22, 2023

Removing -Wsign-compare may paper over legitimate problems. The [now closed] PR actually fixes the code that was making invalid assumptions regarding max values (and so allows the code to compile without warnings even when -Wsign-compare is set).

freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Mar 22, 2023
jhgit added a commit to jhgit/s2n-tls that referenced this issue Mar 22, 2023
Builds on 32-bit or 64-bit x86.

Fixes issue aws#3861 (-Werror=sign-compare fails on 32-bit architectures since 1.3.38).
See also issue aws#3896.

This is a refresh of pull request aws#3868 against the latest master.
@lrstewart
Copy link
Contributor

lrstewart commented Mar 22, 2023

We're aware that sign-compare issues may be legitimate. Unfortunately, none of our CI tests currently run on 32-bit architecture, so we can't definitively validate any fixes and can't guarantee -Wsign-compare won't break again in the near future. To address that problem, we're working on adding 32-bit environments to our CI builds. Once that's done, we can re-enable the -Wsign-compare check by default.

@jhgit
Copy link

jhgit commented Mar 22, 2023

Ok. In the mean time, I re-submitted my changes which should make the code better on 32-bit architectures - PR 3899

I don't understand why the previous PR was closed just because the -Wsign-compare warning was removed. Maybe the thought was that 32-bit fixes won't be considered until a CI for 32-bit is set up?

@lrstewart
Copy link
Contributor

Maybe the thought was that 32-bit fixes won't be considered until a CI for 32-bit is set up?

That's the idea. We can't validate that your changes fix the problem today, and we can't guarantee that we won't accidentally undo them again tomorrow. We need testing.

@jhgit
Copy link

jhgit commented Mar 23, 2023

That's the idea. We can't validate that your changes fix the problem today, and we can't guarantee that we won't accidentally undo them again tomorrow. We need testing.

Understood. Should I close #3899 or let it sit in the queue for a bit? I won't likely notice right away when/if the project gets the 32-bit CI build in place, so if this gets closed, I won't likely submit changes for 32-bit support until I do notice. Maybe that's just the best way to handle it from the project point of view. If it's going to take a while, maybe it's best to close it to avoid clutter of an aging pull request.

@maddeleine
Copy link
Contributor

Understood. Should I close #3899 or let it sit in the queue for a bit? I won't likely notice right away when/if the project gets the 32-bit CI build in place, so if this gets closed, I won't likely submit changes for 32-bit support until I do notice. Maybe that's just the best way to handle it from the project point of view. If it's going to take a while, maybe it's best to close it to avoid clutter of an aging pull request.

You can close #3899. When we add a 32-bit CI build we will turn on the sign-compare check and either reopen your PR or author it ourselves.

@lrstewart lrstewart changed the title 32bit CI build required to fix -Wsign-compare failure on 32 bit architecture Fix -Wsign-compare failures on 32 bit architecture Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants