On Tue, Apr 9, 2013 at 6:28 PM, David Empson <demp...@emptech.co.nz> wrote:
>> No, this is a compiler bug.
>
> It is not a compiler bug. It is a failure of the compiler to deduce that the 
> warning is unnecessary.
>
> [...]
>
> C's usual arithmetic conversions specify that if either operand of a binary 
> operator is an integer type larger than int then the other operand is first 
> converted to the larger type. Therefore p->nBuffer is converted from int to 
> i64 before doing the modulo operation.
>
> We now have i64 % i64, producing a result of type i64.
>
> The statement then stores that i64 result into an int. i64 conversion to int 
> without a cast produces the warning in MSVC (if int is 32-bit).

OK, that's fair.

> The only reason I can see not to have an explicit cast is that it risks 
> hiding a future bug if the types of the variables are changed.

Yes.  Casts to shut up a compiler/lint should be a last resort most often.

Nico
--
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to