why can I pass doubles to "abs"?
Wed Sep 5 00:03:00 GMT 2001
Jennifer Frazier Bryan wrote:
> Hi. I'm using gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2
> release) from the RedHat 6.1 distribution. I cannot get gcc to complain
> when double arguments are passed to "abs". I am including <stdlib.h>,
> I've tried "#undef abs" and "(abs)" to force a function instead of a
> macro. I've also set every -W flag that seems remotely relevant. No
> warnings, no errors -- although it does complain when I do something
> really outrageous, like pass a function pointer to "abs". Please tell me
> where I'm going wrong.
> a) Is it stupid or naive to want a warning when I pass a double argument
> to "abs" (e.g. I obviously menat to use "fabs")?
This is not a normal warning. There is a warning that checks for these
sorts of things: -Wconversion
Warn if a prototype causes a type conversion that is different from
what would happen to the same argument in the absence of a prototype.
This includes conversions of fixed point to floating and vice versa, and
conversions changing the width or signedness of a fixed point argument
except when the same as the default promotion...
> b) Am I failing to tell gcc that I want that kind of a warning?
More information about the Gcc-bugs