Author: robert bristow-johnsonrobert bristow-johnson
Date: Jun 11, 2007 12:25
On Jun 8, 10:33 am, "Douglas A. Gwyn" null.net> wrote:
> robert bristow-johnson wrote:
>> isn't there a way to get this thing to complain when i do an
>> assignment (without explicit casting) of a 32-bit int to a 16-bit
>> int? we know that bits can be potentially dumped in such an
>> assignment. why can't i get this thing to warn me?
>
> That's a job for a tool like "lint".
actually, i think not. this is a compiler issue when an implicit type
conversion (between different flavors of int) *may* cause a change of
value. when building a big project, if you want to impose a
discipline on a bunch of different programmers to not do sloppy
actions that might loose bits somewhere where you won't be looking
(because it is not apparent that any such values were changed in an
expressed equality), these *potential* problems should be flagged in
the build. then you can go into the code, examine it, and if you
think the conversion is kosher, put an explicit cast on it. then the
warning goes away.
|