[cfe-dev] Warnings about automatic demotion in implicit casts?
Chris Lattner
clattner at apple.com
Tue Aug 26 09:40:48 PDT 2008
On Aug 26, 2008, at 7:49 AM, Nikita Zhuk wrote:
> Hi,
>
> Are there any plans to include an option to generate warnings of
> implicit casts which cause automatic demotion (and may thus result in
> loss of information)? For example, the following code doesn't
> currently produce any warnings in clang (gcc with -Wall -pedantic
> doesn't produce any warnings either):
>
> char c = 0; int i = 0; long long ll = 0; float f = 0.0; double d =
> 0.0;
> c = i; c = ll; c = f; c = d;
> i = ll; i = f; i = d;
> ll = f; ll = d;
> f = d;
>
> It would be beneficial to get warnings of all implicit casts which
> cause automatic demotion: in assignments, comparisons, function/method
> parameters and return values. Would this cause too much false
> positives? Should I file a feature request?
It would be very nice to add something like this. If you're
interested, I'd suggest following the lead of the -Wcoercion option
recently added to GCC mainline:
http://gcc.gnu.org/wiki/Wcoercion
-Chris
More information about the cfe-dev
mailing list