From: Jakub Jelinek Date: Mon, 16 Apr 2018 11:22:40 +0000 (+0200) Subject: re PR target/84945 (UBSAN: gcc/config/i386/i386.c:33312:22: runtime error: shift... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a57f99ba1c8f5ece013b9a2cae954338a492764a;p=gcc.git re PR target/84945 (UBSAN: gcc/config/i386/i386.c:33312:22: runtime error: shift exponent 32 is too large for 32-bit type 'int') PR target/84945 * config/i386/cpuinfo.c (set_feature): Wrap into do while (0) to avoid -Wdangling-else warnings. Mask shift counts to avoid -Wshift-count-negative and -Wshift-count-overflow false positives. From-SVN: r259398 --- diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index a715f0b074e..aeaa6539167 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,10 @@ +2018-04-16 Jakub Jelinek + + PR target/84945 + * config/i386/cpuinfo.c (set_feature): Wrap into do while (0) to avoid + -Wdangling-else warnings. Mask shift counts to avoid + -Wshift-count-negative and -Wshift-count-overflow false positives. + 2018-04-06 Ruslan Bukin * config.host (riscv*-*-freebsd*): Add RISC-V FreeBSD support. diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c index 1dac110a79a..86953db2743 100644 --- a/libgcc/config/i386/cpuinfo.c +++ b/libgcc/config/i386/cpuinfo.c @@ -275,7 +275,14 @@ get_available_features (unsigned int ecx, unsigned int edx, } #define set_feature(f) \ - if (f < 32) features |= (1U << f); else features2 |= (1U << (f - 32)) + do \ + { \ + if (f < 32) \ + features |= (1U << (f & 31)); \ + else \ + features2 |= (1U << ((f - 32) & 31)); \ + } \ + while (0) if (edx & bit_CMOV) set_feature (FEATURE_CMOV);