state of clang(1)'s -Wshift-count-negative and -Wshift-overflow warnings

Alexander Best arundel at freebsd.org
Thu Nov 3 10:45:23 UTC 2011


hi there,

i think the following warnings were discussed once before:

In file included from /usr/git-freebsd-head/sys/dev/ath/ath_hal/ah_regdomain.c:99:
/usr/git-freebsd-head/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:69:15: warning: shift count is negative [-Wshift-count-negative]
         .chan11a               = BM4(F1_4950_4980,
                                  ^~~~~~~~~~~~~~~~~
/usr/git-freebsd-head/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:41:4: note: expanded from macro 'BM4'
          W1(_fa) | W1(_fb) | W1(_fc) | W1(_fd) }
          ^
/usr/git-freebsd-head/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h:34:45: note: expanded from macro 'W1'
        (((_a) > 63 && (_a) < 128 ? (((uint64_t) 1)<<((_a)-64)) : (uint64_t) 0))

and

/usr/git-freebsd-head/sys/dev/ath/ath_hal/ar5210/ar5210_power.c:36:3: warning: signed shift result (0x200000000) requires 35 bits to represent, but 'int' only has 32 bits [-Wshift-overflow]
                OS_REG_RMW_FIELD(ah, AR_SCR, AR_SCR_SLE, AR_SCR_SLE_ALLOW);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/git-freebsd-head/sys/dev/ath/ath_hal/ah_internal.h:471:42: note: expanded from macro 'OS_REG_RMW_FIELD'
                (OS_REG_READ(_a, _r) &~ (_f)) | (((_v) << _f##_S) & (_f)))
                                                       ^
/usr/git-freebsd-head/sys/dev/ath/ah_osdep.h:127:49: note: expanded from macro 'OS_REG_WRITE'
            (bus_space_handle_t)(_ah)->ah_sh, (_reg), (_val))

iirc, back then, it was labeled as a clang bug. however testing with clang tot,
i still get those warnings. so i just wanted to ask again, whether the warnings
are really bogus, or if these warnings actually indicate issues during
shifting?

cheers.
alex


More information about the freebsd-toolchain mailing list