On 4/9/2013 7:06 PM, Nico Williams wrote:
On Mon, Apr 8, 2013 at 8:52 AM, Alexandr Němec <a.ne...@atlas.cz> wrote:
The first warning is harmless and results from a prior datatype change.
Dan has already fixed that one.  The other four appear to be due to an
MSVC
compiler bug, since every (i64%int) operation will always yield a value
that can fit in an int, no?

Ok, thank for this comment. Of course, you are right, although I wouldn't
call it a compiler bug. The (i64%int) operation, gives an int result, but
allocated into an i64 value, so this is why the compiler reports the
warning. But thanks, it is obvious now, that these warnings can be ignored.

The compiler is complaining about an int64->int conversion, not the reverse.

Why on Earth would going from an int (64-bit or smaller) to an int64
cause a problem?

Without looking at the code, I imagine the result is ultimately assigned to an int variable. That's what triggers the warning. Something like this:

int64 A = ...;
int B = ...;
int C = A % B;

Formally, the type of the expression (A % B) is int64, thanks to integral promotion (chapter and verse from the C++ standard is available upon request). That result is then assigned to an int variable, formally necessitating a narrowing conversion, which triggers the warning.

However, the nature of modulo operator is such that the value of A % B is less than B, and since B is an int, the value of (A % B) is guaranteed to fit into an int without loss. A smarter compiler could have realized that, and suppressed the warning.

This is not technically a bug (defined as non-conformance with the standard), but a quality-of-implementation issue.
--
Igor Tandetnik

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

Reply via email to