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

GCC Conversion Warnings #105

Closed
phillipjohnston opened this issue Jan 25, 2022 · 3 comments
Closed

GCC Conversion Warnings #105

phillipjohnston opened this issue Jan 25, 2022 · 3 comments
Assignees
Labels
resolved-on-develop A changeset fixing this issue has been commiutted to the development branch task

Comments

@phillipjohnston
Copy link

GCC with -Wconversion highlights conversions that may change values.

[243/533] Compiling C object src/libc.a.p/.._printf_src_printf_printf.c.o
../printf/src/printf/printf.c: In function 'get_sign':
../printf/src/printf/printf.c:275:30: warning: conversion from 'double_uint_t' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
  275 |   return get_bit_access(x).U >> (DOUBLE_SIZE_IN_BITS - 1);
      |          ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../printf/src/printf/printf.c: In function 'get_components':
../printf/src/printf/printf.c:528:34: warning: conversion from 'int_fast64_t' {aka 'long long int'} to 'double' may change value [-Wconversion]
  528 |   double remainder = (abs_number - number_.integral) * powers_of_10[precision];
      |                                  ^
../printf/src/printf/printf.c:618:22: warning: conversion from 'int_fast64_t' {aka 'long long int'} to 'double' may change value [-Wconversion]
  618 |     scaled_remainder -= components.fractional;
      |                      ^~

I can resolve these in a PR with the proper casts, but I wanted you to take a look first in case you think some of them should be resolved through other means.

@phillipjohnston
Copy link
Author

(This is on develop)

eyalroz added a commit that referenced this issue Jan 25, 2022
…t, and some additional minor changes:

* Now compiling with the `-Wconversion` warning flag when using clang or gcc.
* In all cases noticed by gcc in which an implicit conversion was made which could change the converted value - have changed the conversion to be explicit.
* Renamed: `get_sign()` -> `get_sign_bit()` (so as to clarify the return value is either 0 or 1, not -1 or 1).
* Added explanatory comment for the `double_components` structure.
@eyalroz
Copy link
Owner

eyalroz commented Jan 25, 2022

Fixed this, and added -Wconversion myself. When a warning can just be avoided, I have no trouble obliging.

@eyalroz eyalroz self-assigned this Jan 25, 2022
@eyalroz eyalroz added task resolved-on-develop A changeset fixing this issue has been commiutted to the development branch labels Jan 25, 2022
@phillipjohnston
Copy link
Author

Thanks!

eyalroz added a commit that referenced this issue Jan 26, 2022
…t, and some additional minor changes:

* Now compiling with the `-Wconversion` warning flag when using clang or gcc.
* In all cases noticed by gcc in which an implicit conversion was made which could change the converted value - have changed the conversion to be explicit.
* Renamed: `get_sign()` -> `get_sign_bit()` (so as to clarify the return value is either 0 or 1, not -1 or 1).
* Added explanatory comment for the `double_components` structure.
eyalroz added a commit that referenced this issue Jan 26, 2022
…t, and some additional minor changes:

* Now compiling with the `-Wconversion` warning flag when using clang or gcc.
* In all cases noticed by gcc in which an implicit conversion was made which could change the converted value - have changed the conversion to be explicit.
* Renamed: `get_sign()` -> `get_sign_bit()` (so as to clarify the return value is either 0 or 1, not -1 or 1).
* Added explanatory comment for the `double_components` structure.
eyalroz added a commit that referenced this issue Jan 31, 2022
…t, and some additional minor changes:

* Now compiling with the `-Wconversion` warning flag when using clang or gcc.
* In all cases noticed by gcc in which an implicit conversion was made which could change the converted value - have changed the conversion to be explicit.
* Renamed: `get_sign()` -> `get_sign_bit()` (so as to clarify the return value is either 0 or 1, not -1 or 1).
* Added explanatory comment for the `double_components` structure.
eyalroz added a commit that referenced this issue Jan 31, 2022
…t, and some additional minor changes:

* Now compiling with the `-Wconversion` warning flag when using clang or gcc.
* In all cases noticed by gcc in which an implicit conversion was made which could change the converted value - have changed the conversion to be explicit.
* Renamed: `get_sign()` -> `get_sign_bit()` (so as to clarify the return value is either 0 or 1, not -1 or 1).
* Added explanatory comment for the `double_components` structure.
eyalroz added a commit that referenced this issue Jan 31, 2022
…t, and some additional minor changes:

* Now compiling with the `-Wconversion` warning flag when using clang or gcc.
* In all cases noticed by gcc in which an implicit conversion was made which could change the converted value - have changed the conversion to be explicit.
* Renamed: `get_sign()` -> `get_sign_bit()` (so as to clarify the return value is either 0 or 1, not -1 or 1).
* Added explanatory comment for the `double_components` structure.
eyalroz added a commit that referenced this issue Feb 7, 2022
…t, and some additional minor changes:

* Now compiling with the `-Wconversion` warning flag when using clang or gcc.
* In all cases noticed by gcc in which an implicit conversion was made which could change the converted value - have changed the conversion to be explicit.
* Renamed: `get_sign()` -> `get_sign_bit()` (so as to clarify the return value is either 0 or 1, not -1 or 1).
* Added explanatory comment for the `double_components` structure.
eyalroz added a commit that referenced this issue Feb 10, 2022
…t, and some additional minor changes:

* Now compiling with the `-Wconversion` warning flag when using clang or gcc.
* In all cases noticed by gcc in which an implicit conversion was made which could change the converted value - have changed the conversion to be explicit.
* Renamed: `get_sign()` -> `get_sign_bit()` (so as to clarify the return value is either 0 or 1, not -1 or 1).
* Added explanatory comment for the `double_components` structure.
eyalroz added a commit that referenced this issue Feb 11, 2022
…t, and some additional minor changes:

* Now compiling with the `-Wconversion` warning flag when using clang or gcc.
* In all cases noticed by gcc in which an implicit conversion was made which could change the converted value - have changed the conversion to be explicit.
* Renamed: `get_sign()` -> `get_sign_bit()` (so as to clarify the return value is either 0 or 1, not -1 or 1).
* Added explanatory comment for the `double_components` structure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolved-on-develop A changeset fixing this issue has been commiutted to the development branch task
Projects
None yet
Development

No branches or pull requests

2 participants