strtod_l.c from glibc-2.7 produces following warnings and Ian Lance Taylor said at the least for warning should only be issued with -Wstrict-overflow=3. strtod_l.c:1009: warning: assuming signed overflow does not occur when changing X +- C1 cmp C2 to X cmp C1 +- C2 strtod_l.c:1358: warning: assuming signed overflow does not occur when simplifying conditional to constant strtod_l.c:1358: warning: assuming signed overflow does not occur when simplifying conditional to constant strtod_l.c:1410: warning: assuming signed overflow does not occur when simplifying conditional to constant strtod_l.c:1410: warning: assuming signed overflow does not occur when simplifying conditional to constant strtod_l.c:1531: warning: assuming signed overflow does not occur when simplifying conditional to constant strtod_l.c:1531: warning: assuming signed overflow does not occur when simplifying conditional to constant
Created attachment 14787 [details] Preprocessed source
s/for warning/first warning
Hmm: if (bits == 0) { register int cnt; if (quot == 0) cnt = 32; else do { USItype __cbtmp; __asm__ ("bsrl %1,%0" : "=r" (__cbtmp) : "rm" ((USItype) (quot))); (cnt) = __cbtmp ^ 31; } while (0); exponent -= cnt; if (32 - cnt > 53) { used = 53 + cnt; retval[0] = quot >> (32 - used); bits = 53 + 1; } else { if ((((53) + ((32) - 1)) / (32)) > 1) retval[1] = 0; retval[0] = quot; bits = -cnt; } } else if (bits + 32 <= 53) __mpn_lshift_1 (retval, (((53) + ((32) - 1)) / (32)), 32, quot); else { used = 53 - bits; if (used > 0) __mpn_lshift_1 (retval, (((53) + ((32) - 1)) / (32)), used, quot); } bits += 32; Maybe this is not a compiler bug. There are at least two expressions where the first warning is ovbious correct.
retval[idx--] |= val >> (4 - pos - 1); val <<= 32 - (4 - pos - 1); if (idx < 0) For the first warning, even though the warning is correct, I don't think we should warn here as the expressions are split between two different statements. do { mp_size_t __i; for (__i = 0; __i < (idx); __i++) (retval)[__i] = 0; } while (0); For the second but I think that one should not be warned about.
This is too large to analyze and it doesn't compile cleanly: strtod_l.c:1318:8: error: lvalue required in asm statement strtod_l.c:1318:8: error: lvalue required in asm statement I don't think it is useful to keep it around. Better focus on other -Wstrict-overflow PRs.