[cfe-dev] Missing -Wshorten-64-to-32 for operator+=
Milan Kříž via cfe-dev
cfe-dev at lists.llvm.org
Fri Jul 24 02:04:11 PDT 2020
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?
Mi-L@
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2226 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200724/0edb6475/attachment-0001.bin>
More information about the cfe-dev
mailing list