[cfe-dev] Warnings about automatic demotion in implicit casts?

Nikita Zhuk nikita at zhuk.fi
Tue Aug 26 07:49:55 PDT 2008


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?

- Nikita

More information about the cfe-dev mailing list