It's very annoying that the gcc compiler option that would flag this automatically (-Wconversion) also trips over so many false positives that it is basically useless.
thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
AFAIK, warning actually produced by clang, a different and very
useful C / C++ compiler.
Here is more of the same from clang
../../src/mouse.c:2051:13: warning: using floating point absolute value function
'fabs' when argument is of integer type [-Wabsolute-value]
../../src/mouse.c:2052:13: warning: using floating point absolute value function
'fabs' when argument is of integer type [-Wabsolute-value]
../../src/plot2d.c:3443:50: warning: using integer absolute value function 'abs'
when argument is of floating point type [-Wabsolute-value]
../../src/plot2d.c:3445:25: warning: using integer absolute value function 'abs'
when argument is of floating point type [-Wabsolute-value]
../../src/plot2d.c:3448:21: warning: using integer absolute value function 'abs'
when argument is of floating point type [-Wabsolute-value]
../../src/stats.c:222:8: warning: using integer absolute value function 'abs' wh
en argument is of floating point type [-Wabsolute-value]
../../src/wxterminal/gp_cairo.c:1156:22: warning: using floating point absolute
value function 'fabs' when argument is of integer type [-Wabsolute-value]
../../src/wxterminal/gp_cairo.c:1157:22: warning: using floating point absolute
value function 'fabs' when argument is of integer type [-Wabsolute-value]
Suggest that if gcc is weak in some areas, then use clang as well.
So you increase your chances of finding bugs.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Righto. Now I see your problem. Suggest start by fixing the eight
or so I mentioned from clang.
For the four warnings you mention, #2 and #4 look the most important.
Suggest grep for those warning message patterns only, to start with.
I've also had good results with a static analyser called cppcheck.
While it doesn't help in this case, it might be useful for other
messages it produces.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
gnuplot uses a mixture of floating point and integer math throughout, intentionally. In general floating point computation is used up until terminal coordinates are needed, but these are always integers.
The problem is that -Wconversion in clang doesn't distinguish between double->int conversion as a result of assigment, which is very probably intentional and correct as in,
terminal_x_coord = floating_expression()
and implicit conversion as a result of function parameter mismatch, like the one with abs(x) that you caught. I want a "-Wno-conversion-on-assignment" flag but there doesn't seem to be one.
My clang (3.3 33/final) doesn't seem to have a -Wabsolute-value option. Is that a recent addition?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yup. You caught a bug.
It's very annoying that the gcc compiler option that would flag this automatically (-Wconversion) also trips over so many false positives that it is basically useless.
But gcc doesn't understand -Wabsolute-value flag.
AFAIK, warning actually produced by clang, a different and very
useful C / C++ compiler.
Here is more of the same from clang
../../src/mouse.c:2051:13: warning: using floating point absolute value function
'fabs' when argument is of integer type [-Wabsolute-value]
../../src/mouse.c:2052:13: warning: using floating point absolute value function
'fabs' when argument is of integer type [-Wabsolute-value]
../../src/plot2d.c:3443:50: warning: using integer absolute value function 'abs'
when argument is of floating point type [-Wabsolute-value]
../../src/plot2d.c:3445:25: warning: using integer absolute value function 'abs'
when argument is of floating point type [-Wabsolute-value]
../../src/plot2d.c:3448:21: warning: using integer absolute value function 'abs'
when argument is of floating point type [-Wabsolute-value]
../../src/stats.c:222:8: warning: using integer absolute value function 'abs' wh
en argument is of floating point type [-Wabsolute-value]
../../src/wxterminal/gp_cairo.c:1156:22: warning: using floating point absolute
value function 'fabs' when argument is of integer type [-Wabsolute-value]
../../src/wxterminal/gp_cairo.c:1157:22: warning: using floating point absolute
value function 'fabs' when argument is of integer type [-Wabsolute-value]
Suggest that if gcc is weak in some areas, then use clang as well.
So you increase your chances of finding bugs.
Actually, I do use clang in addition to gcc for exactly this purpose. The problem is that even if I try to cut down on the noise by using
I still get hundreds (>800) false positives such as
There may be real bugs hiding in there, but the noise level is too high to find them easily.
Righto. Now I see your problem. Suggest start by fixing the eight
or so I mentioned from clang.
For the four warnings you mention, #2 and #4 look the most important.
Suggest grep for those warning message patterns only, to start with.
I've also had good results with a static analyser called cppcheck.
While it doesn't help in this case, it might be useful for other
messages it produces.
gnuplot uses a mixture of floating point and integer math throughout, intentionally. In general floating point computation is used up until terminal coordinates are needed, but these are always integers.
The problem is that -Wconversion in clang doesn't distinguish between double->int conversion as a result of assigment, which is very probably intentional and correct as in,
and implicit conversion as a result of function parameter mismatch, like the one with abs(x) that you caught. I want a "-Wno-conversion-on-assignment" flag but there doesn't seem to be one.
My clang (3.3 33/final) doesn't seem to have a -Wabsolute-value option. Is that a recent addition?
Current clang is version 3.5 and 3.3 is dated Jun 2013.