|
- Warning Options (Using the GNU Compiler Collection (GCC))
-Wshift-overflow=1 This is the warning level of -Wshift-overflow and is enabled by default in C99 and C++11 modes (and newer) This warning level does not warn about left-shifting 1 into the sign bit
- How to get rid of C macro -Wshift-count-overflow warning
As PJ suggested, casting to appropriate type will get rid of the warning Adding my two cents, I would suggest to cast to uint64_t if you don't care about signed or unsigned value Using uint64_t will give you the raw binary pattern
- 104711 – Unnecessary -Wshift-negative-value warning
This warning is enabled by default at the -Wextra level for C99 GNU99 or higher, but disabled for C89 GNU89 In clang, the warning is enabled by default at the -Wall level but in turn disabled when building with -fwrapv or -fno-strict-overflow (as the Linux kernel does)
- Understanding GCC warnings - Red Hat Developer
All the -Wshift- warnings (-Wshift-count-negative, -Wshift-count-overflow, -Wshift-negative-value, and -Wshift-overflow) fall into this category because their efficacy depends on GCC's ability to determine the value of one of the operands of the shift expression
- Left shift count gt;= width of type [-Wshift-count-overflow]
As you do this on purpose you probably don’t mind the loss of information and you can ignore the warning If you want to get rid of the warning you would have to cast the return value of Wire read() to a bigger type and also change data to be a bigger type
- Using the GNU Compiler Collection (GCC): Warning Options
-Wshift-overflow=1 This is the warning level of -Wshift-overflow and is enabled by default in C99 and C++11 modes (and newer) This warning level does not warn about left-shifting 1 into the sign bit
- Silencing a -Wshift-count-overflow warning in a generic bitmask macro
but when I use it, it's generating -Wshift-count-overflow warnings Can these warnings be silenced from within the macro? I don't want to silence them altogether because e g , the UB-causing ((int32_t)1)<<32 should still get a warning, but ((uint_least32_t)1)<<32 overflowing to 0 is completely harmless and intended Example program:
- 88895 – unnecessary -Wshift-count-overflow in unreachable code (shift)
Basically, g++ is warning about undefined shifts too early; it should wait until code generation and see what unreachable code is weeded out The attachment shows a standard idiom for packing arbitrary integer types into buffer in big endian fashion, regardless of the endianness of the platform g++ generates the correct code (which melts down
|
|
|