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

Remove explicit casts from some integer constants, to improve readability #72

Open
BarryBo opened this issue Nov 30, 2017 · 2 comments
Open

Comments

@BarryBo
Copy link
Contributor

BarryBo commented Nov 30, 2017

Kremlin is careful to produce constant values with predictable behavior, despite ambiguities in C about integer promotion due to sizeof(int) and signed-ness of char.

Examples:

  • (uint32_t)1U

  • (uint32_t)0U

  • (int32_t)1

  • (int32_t)0

I think Kremlin could omit the casts in a number of cases, while still being certain that the ambiguous cases are well handled. I believe it is safe for constants < 16 bits in length, where it already emits the 'U' suffix for unsigned, or omits it for signed.

For larger constants, close to sizeof(int) on a 16-bit machine, the explicit casts will still be important.

@beurdouche
Copy link
Member

Note that HACL* is running on 16bit platforms through the RIOT operating system.

@msprotz
Copy link
Contributor

msprotz commented May 24, 2018

what is the data model for these platforms?

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

No branches or pull requests

3 participants