[vlc-devel] [PATCH 17/22] vlc_arrays: DictHash output is always used as an int

Steve Lhomme robux4 at videolabs.io
Mon Aug 3 14:51:20 CEST 2015

On Mon, Aug 3, 2015 at 2:30 PM, Rémi Denis-Courmont <remi at remlab.net> wrote:
> Le 2015-08-02 22:24, Filipe Cabecinhas a écrit :
>>> Of course not. Conversion from an integer type to a *signed*
>>> integer type is
>>> always exact in C. The number of bits of both types is irrelevant.
>> Its implementation dependent but exact, yes.
> No. Just no.
> The spec says it is exact, GCC and clang assume it is exact, and VLC uses it
> such that it is exact.
>> What Im saying is that int might be 32 bits
>> and you might only get the bottom 32 bits
> No. No. No. You get the same value. The high-order zero bits will be
> discarded, but that does obviously not change the actual value.

You get the same value with and without the cast, yes. But different
input may produce the same hash output and that could be a problem. We
should either output a uint64_t from this function or explain we don't
want the extra precision (using a cast ?).

> MSVC seems to have either some super-strict or super-dumb overflow warnings.
> I was not able to find an equivalent warning in GCC (-Wstrict-overflow does
> not seem to cover type conversions).

How about -Wconversion ?

> --
> Rémi Denis-Courmont
> http://www.remlab.net/
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel

More information about the vlc-devel mailing list