On 25 Sep 2019, at 15:36, Ed Maste <ema...@freebsd.org> wrote: > > On Tue, 24 Sep 2019 at 17:39, Bruce Evans <b...@optusnet.com.au> wrote: >> >> On i386, these types have different sizes, so >> gcc detects the type mismatch. clang is too broken to report this type >> mismatch. > > Interesting, it seems Clang doesn't even warn in the case of casting a > uint64_t to a 32-bit pointer. Looks like there are some useful > warnings that ought to be implemented.
There is -Wconversion for this, or the more specific -Wshorten-64-to-32: $ cat shorten.c int foo(long l) { return l; } $ clang -Wconversion -c shorten.c shorten.c:3:10: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] return l; ~~~~~~ ^ 1 warning generated. But for some reason this warning isn't enabled by default, even with -Wall. I guess you would get a zillion warnings on our tree, if you enabled this. :) -Dimitry
signature.asc
Description: Message signed with OpenPGP