[cfe-commits] r162109 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaCast.cpp test/Sema/warn-bad-function-cast.c

jahanian fjahanian at apple.com
Fri Aug 17 11:47:49 PDT 2012


On Aug 17, 2012, at 11:11 AM, Matt Beaumont-Gay wrote:

> Can you explain the rationale behind this warning a little bit? It
> fires on some more-or-less reasonable code like this snippet from the
> Python Imaging Library:
> 
> libImaging/Draw.c:448:51: error: cast from function call of type
> 'double' to non-matching type 'int' [-Werror,-Wbad-function-cast]
>                hline8(im, CEIL(xx[0]-0.5), ymin, FLOOR(xx[1]+0.5), ink);
>                                                  ^~~~~~~~~~~~~~~~
> libImaging/Draw.c:40:50: note: expanded from macro 'FLOOR'
> #define FLOOR(v) ((v) >= 0.0 ? (int) (v) : (int) floor(v))
>                                                 ^~~~~~~~
> 

It shouldn't be under -Wall. gcc does not and you just convinced me further. It is
something some one might find useful to have (and got it implemented on gcc).
More interesting cases are (int)ptrFunc(), etc. 

- Thanks, Fariborz





More information about the cfe-commits mailing list