-
Notifications
You must be signed in to change notification settings - Fork 491
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
Undefined behavior on INT_MIN #118
Comments
eyalroz
added a commit
to eyalroz/printf
that referenced
this issue
Aug 2, 2021
…nsigned integer types; regards issue mpaland#118.
eyalroz
added a commit
to eyalroz/printf
that referenced
this issue
Aug 2, 2021
* Added comment explaining how we "narrowly escape" undefined behavior with our `NTOA_ABS()` macro. * Added checks for printing extremal values of the various signed and unsigned integer types, just in case.
... and luckily, this seems to be averted on the fork. |
eyalroz
added a commit
to eyalroz/printf
that referenced
this issue
Aug 3, 2021
* Added comment explaining how we "narrowly escape" undefined behavior with our `NTOA_ABS()` macro. * Added checks for printing extremal values of the various signed and unsigned integer types, just in case.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The library has undefined behavior in some cases, due to applying the unary negation operator indiscriminately. For example, when we print:
we internally have an
int value
variable with valueINT_MIN
, and then we take-value
(or0 - value
). That's undefined! Not good.The text was updated successfully, but these errors were encountered: