Package: gcc-11 Version: 11.2.0-3 Severity: important Tags: upstream Forwarded: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98447
Compiling the following code with "gcc-11 -fanalyzer -c" void f (unsigned long *p, int r, int i) { int b = 64, n = r % 64; while (i >= 0 && b >= 0) { if (b <= n) p[i--] = 1UL << b; b -= n; } } gives: warn-shiftcount.c: In function ‘f’: warn-shiftcount.c:8:22: warning: shift by count (‘64’) >= precision of type (‘6’) [-Wanalyzer-shift-count-overflow] 8 | p[i--] = 1UL << b; | ~~~~^~~~ ‘f’: events 1-5 | | 5 | while (i >= 0 && b >= 0) | | ~~~~~~~^~~~~~~~~ | | | | | (1) following ‘true’ branch... | 6 | { | 7 | if (b <= n) | | ~ | | | | | (2) ...to here | | (3) following ‘true’ branch (when ‘b <= n’)... | 8 | p[i--] = 1UL << b; | | ~~~ ~~~~~~~~ | | | | | | | (5) shift by count ‘64’ here | | (4) ...to here This warning is incorrect, since 1UL << b is in the "if" branch, where b <= n and n <= 63 (thus b <= 63). No such issue with gcc-10 and before. This makes testing of GNU MPFR fail (this testcase was derived from GNU MPFR's random2.c). -- System Information: Debian Release: bookworm/sid APT prefers unstable-debug APT policy: (500, 'unstable-debug'), (500, 'stable-security'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 5.10.0-8-amd64 (SMP w/8 CPU threads) Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=POSIX, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages gcc-11 depends on: ii binutils 2.37-4 ii cpp-11 11.2.0-3 ii gcc-11-base 11.2.0-3 ii libc6 2.31-17 ii libcc1-0 11.2.0-3 ii libgcc-11-dev 11.2.0-3 ii libgcc-s1 11.2.0-3 ii libgmp10 2:6.2.1+dfsg-1 ii libisl23 0.23-1 ii libmpc3 1.2.0-1 ii libmpfr6 4.1.0-3 ii libstdc++6 11.2.0-3 ii libzstd1 1.4.8+dfsg-2.1 ii zlib1g 1:1.2.11.dfsg-2 Versions of packages gcc-11 recommends: ii libc6-dev 2.31-17 Versions of packages gcc-11 suggests: pn gcc-11-doc <none> ii gcc-11-locales 11.2.0-3 ii gcc-11-multilib 11.2.0-3 -- no debconf information -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)