[PATCH] Add a truncation warning for values under a bitwise or

Dmitri Gribenko gribozavr at gmail.com
Thu Feb 21 12:46:44 PST 2013



================
Comment at: test/Sema/constant-conversion.c:92
@@ +91,3 @@
+  unsigned char y = 0;
+	x = y | 0x1ff; // expected-warning {{implicit conversion from 'int' to 'unsigned char' changes value from 511 to 255}}
+	x = y | 0xff; // no-warning
----------------
The message in all these cases is a bit misleading.  It suggest that we do the computation as `x = y | char(0x1ff)`, while in reality it is `x = char(int(x) | 0x1ff)`.

Do you think this is an issue?  Is there a better wording?



http://llvm-reviews.chandlerc.com/D405



More information about the cfe-commits mailing list