Skip to content

Fix for [-Wtype-limits] compiler warning on 32bits platforms in Sodium extension #5304

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

Closed

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Mar 26, 2020

To achieve this we use no-op operations which force the conversion to unsigned long long

This was flagged while working on #5151, just putting this up as a PR as a sanity check and see if someone else has a better idea how to go about it.

@nikic
Copy link
Member

nikic commented Mar 26, 2020

I would prefer to wrap this in a #if SIZEOF_SIZE_T != 4 block. Adding the dummy multiplication seems prone to break with newer compiler versions.

@cmb69
Copy link
Member

cmb69 commented Mar 26, 2020

This patch looks bogus, since the left hand side of the expression is already unsigned long long. The actual "problem" here is that msg_len is declared as size_t which has 32bits on x86, but the right hand side of the comparison is way larger. See Nikita's comment above for a possible solution.

@cmb69
Copy link
Member

cmb69 commented Mar 26, 2020

Forgot: this should also go into https://github.com/jedisct1/libsodium-php, or maybe only to there (and later back-ported).

@Girgias
Copy link
Member Author

Girgias commented Mar 26, 2020

I would prefer to wrap this in a #if SIZEOF_SIZE_T != 4 block. Adding the dummy multiplication seems prone to break with newer compiler versions.

That seems better in all aspects.

Forgot: this should also go into https://github.com/jedisct1/libsodium-php, or maybe only to there (and later back-ported).

Will send a PR upstream then

@Girgias Girgias force-pushed the fix-compiler-warning-sodium-32bits branch from 198e6ae to 1cb8764 Compare March 26, 2020 16:50
@Girgias
Copy link
Member Author

Girgias commented Mar 26, 2020

This has been declined upstream, will just add a specific compiler flag to this extension to suppress those warnings.

@Girgias Girgias closed this Mar 26, 2020
@Girgias Girgias deleted the fix-compiler-warning-sodium-32bits branch March 26, 2020 20:10
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 this pull request may close these issues.

3 participants