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

Compilation warnings with GCC #102

Open
eyalroz opened this issue Jun 28, 2021 · 0 comments
Open

Compilation warnings with GCC #102

eyalroz opened this issue Jun 28, 2021 · 0 comments

Comments

@eyalroz
Copy link

eyalroz commented Jun 28, 2021

Hello Marco,

Thanks for making this available.

When compiling with GCC (8.4) I get a few spurious compilation warnings:

In file included from test/test_suite.cpp(41) :
test/../printf.c: In function ‘size_t test() :_ftoa(test::out_fct_type, char*, size_t, size_t, double, unsigned int, unsigned int, unsigned int)’:
test/../printf.c(349) :16: warning: comparing floating point with == or != is unsafe [-Wfloat-equal]
   if (value != value)
                ^~~~~
test/../printf.c: In function ‘size_t test() :_etoa(test::out_fct_type, char*, size_t, size_t, double, unsigned int, unsigned int, unsigned int)’:
test/../printf.c(470) :17: warning: comparing floating point with == or != is unsafe [-Wfloat-equal]
   if ((value != value) || (value > DBL_MAX) || (value < -DBL_MAX)) {
                 ^~~~~
test/../printf.c(564) :61: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
     idx = _ntoa_long(out, buffer, idx, maxlen, (expval < 0) ? -expval : expval, expval < 0, 10, 0, minwidth-1, FLAGS_ZEROPAD | FLAGS_PLUS);
                                                ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
test/test_suite.cpp: In function ‘void ____C_A_T_C_H____T_E_S_T____48()’:
test/test_suite.cpp(1088) :33: warning: implicit conversion from ‘float’ to ‘double’ when passing argument to function [-Wdouble-promotion]
   test() :sprintf(buffer, "%-8f", -INFINITY);
                                 ^
test/test_suite.cpp(1220) :37: warning: implicit conversion from ‘float’ to ‘double’ when passing argument to function [-Wdouble-promotion]
     test() :sprintf(buffer, "%.5f", i / 10000);
                                   ~~^~~~~~~
test/test_suite.cpp(1231) :27: warning: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Wdouble-promotion]
   for (float i = -1e20; i < 1e20; i += 1e15) {
                         ~~^~~~~~
test/test_suite.cpp(1231) :37: warning: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Wdouble-promotion]
   for (float i = -1e20; i < 1e20; i += 1e15) {
                                   ~~^~~~~~~
test/test_suite.cpp(1232) :35: warning: implicit conversion from ‘float’ to ‘double’ when passing argument to function [-Wdouble-promotion]
     test() :sprintf(buffer, "%.5f", i);
                                   ^

It should not be difficult to avoid them.

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

1 participant