[cfe-dev] Missing -Wshorten-64-to-32 for operator+=
Shoaib Meenai via cfe-dev
cfe-dev at lists.llvm.org
Tue Jul 28 00:03:44 PDT 2020
I'd filed https://bugs.llvm.org/show_bug.cgi?id=33559 for this quite a while back, although I never got the chance to look into it more.
On 7/27/20, 9:04 PM, "cfe-dev on behalf of John McCall via cfe-dev" <cfe-dev-bounces at lists.llvm.org on behalf of cfe-dev at lists.llvm.org> wrote:
On 24 Jul 2020, at 5:04, Milan Kříž via cfe-dev wrote:
> Hi,
>
> I have found that operator+= doesn't fire -Wshorten-64-to-32 warning,
> while pure opreator+ fires it. See the following example:
>
> #include <stdint.h>
>
> int main()
> {
> uint32_t test = 0;
> uint64_t test64 = UINT32_MAX + 1;
> test += test64;// doesn't fire the warning
> test = test + test64; // fires the warning: implicit conversion
> loses integer precision: 'unsigned long' to 'uint32_t' (aka 'unsigned
> int') [-Wshorten-64-to-32]
> }
>
> I've found this in 32-bit build while adding uint64_t to size_t
> (size_t has 4 byte on 32-bit) variable (Clang didn't warn me while
> MSVC surprisingly did :-)).
>
> Should I post a bug-report or is it some known exception where the
> warning should not occur?
Please file a bug. There’s no reason for the warning to not fire on
compound operators like it would on the expanded form.
John.
>
> Mi-L@
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Ddev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=VVQZ_VwovdijqjDSZNSKTp9kTFWVSYtl0iTOKmzW16k&s=8pN4RKYZ5W9xgZveUXhjilV-AAJWYtZRKese1aALS8A&e=
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Ddev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=VVQZ_VwovdijqjDSZNSKTp9kTFWVSYtl0iTOKmzW16k&s=8pN4RKYZ5W9xgZveUXhjilV-AAJWYtZRKese1aALS8A&e=
More information about the cfe-dev
mailing list