Apple's LLVM does not warn about this problem, even when -Wall
is specified:
uint8_t tta;
typedef uint32_t TT;
TT ttb;
ttb= 0xdeadbeef;
tta = ttb;
// here tta is only 0xEF
What can be done to force the compiler to warn about loss of data during assignment?
If you use -Wconversion
you get a warning:
<stdin>:9:7: warning: implicit conversion loses integer precision: 'TT' (aka 'unsigned int') to 'uint8_t' (aka 'unsigned char') [-Wconversion]
tta = ttb;
~ ^~~
1 warning generated.
This was generated by the current release version of Apple's developer tools:
Apple LLVM version 8.1.0 (clang-802.0.42)
User contributions licensed under CC BY-SA 3.0