Bug 34515 - -Wstrict-overflow produces extra warnings
Summary: -Wstrict-overflow produces extra warnings
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-17 20:41 UTC by İsmail Dönmez
Modified: 2018-09-16 16:54 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Preprocessed source (41.05 KB, application/octet-stream)
2007-12-17 20:42 UTC, İsmail Dönmez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description İsmail Dönmez 2007-12-17 20:41:57 UTC
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
Comment 1 İsmail Dönmez 2007-12-17 20:42:24 UTC
Created attachment 14787 [details]
Preprocessed source
Comment 2 İsmail Dönmez 2007-12-17 20:42:59 UTC
s/for warning/first warning
Comment 3 Andrew Pinski 2007-12-17 21:34:10 UTC
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.
Comment 4 Andrew Pinski 2007-12-17 21:38:29 UTC
       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.
Comment 5 Manuel López-Ibáñez 2018-09-16 16:54:47 UTC
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.