https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85425

--- Comment #2 from Gerhard Heinzel <gerhard.heinzel at aei dot mpg.de> ---
(In reply to Jonathan Wakely from comment #1)

Many thanks for your quick response. 
I normally don't use -Wconversion because it floods me with
uninteresting errors about size_t, floor(), and code from bison/flex etc. 
But I'll try to use it more now.

Cheers,

Gerhard


> The example can be reduced to:
> 
> void ghhrobust_search (double ay, int type) { }
> 
> void f(int i, double d) { ghhrobust_search(i, d); }
> 
> This must not produce an error, because it is 100% valid according to the C
> standard. An int can be converted to a double and a double can be converted
> to an int, so the code is valid.
> 
> If you use -Wconversion you get a warning:
> 
> 
> a.c: In function ‘void f(int, double)’:
> a.c:3:48: warning: conversion to ‘int’ from ‘double’ may alter its value
> [-Wfloat-conversion]
>  void f(int i, double d) { ghhrobust_search(i, d); }
>                                                 ^
> 
> This seems to be what you're looking for. Indeed, compiling your attached
> code with -Wconversion gives a warning on the relevant line:
> 
> fail_contour.c: In function ‘contour_trace’:
> fail_contour.c:203:56: warning: conversion to ‘int’ from ‘double’ may alter
> its value [-Wfloat-conversion]

Reply via email to