| Summary: | UBSAN: false positive as a result of distribution: c1*(c2*v1-c3*v2)=>c1*c2*v1-c1*c3*v2 | ||
|---|---|---|---|
| Product: | gcc | Reporter: | Dmitry Babokin <babokin> |
| Component: | sanitizer | Assignee: | Marek Polacek <mpolacek> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | dimhen, dodji, jakub, kcc, rguenth |
| Priority: | P3 | Keywords: | wrong-code |
| Version: | 8.0 | ||
| Target Milestone: | --- | ||
| Host: | Target: | ||
| Build: | Known to work: | ||
| Known to fail: | Last reconfirmed: | 2017-06-01 00:00:00 | |
| Bug Depends on: | |||
| Bug Blocks: | 103035 | ||
|
Description
Dmitry Babokin
2017-05-31 21:00:22 UTC
Confirmed. I'll take a look. Better testcase (C and C++):
int x = 1;
long int
foo (void)
{
return ((long) (13801962912760474560ULL * x) - (long) (15334142073106273231ULL * x)) * -6;
}
int
main ()
{
foo ();
return 0;
}
Should've been in ASSIGNED. Author: mpolacek Date: Wed Jun 7 11:19:40 2017 New Revision: 248961 URL: https://gcc.gnu.org/viewcvs?rev=248961&root=gcc&view=rev Log: PR sanitizer/80932 * fold-const.c (extract_muldiv_1) <case MINUS_EXPR>: Add TYPE_OVERFLOW_WRAPS check. * c-c++-common/ubsan/pr80932.c: New test. Added: trunk/gcc/testsuite/c-c++-common/ubsan/pr80932.c Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog Fixed. New failures: FAIL: c-c++-common/ubsan/pr80932.c -O0 execution test FAIL: c-c++-common/ubsan/pr80932.c -O0 execution test Can't reproduce. What arch, is that gcc or g++, ... https://gcc.gnu.org/ml/gcc-regression/2017-06/msg00104.html https://gcc.gnu.org/ml/gcc-regression/2017-06/msg00105.html https://gcc.gnu.org/ml/gcc-regression/2017-06/msg00107.html trunk (checking=release): trippels@gcc67 gcc % gcc -O0 -fsanitize=undefined ./gcc/testsuite/c-c++-common/ubsan/pr80932.c trippels@gcc67 gcc % ./a.out gcc/testsuite/c-c++-common/ubsan/pr80932.c:10:88: runtime error: signed integer overflow: -9024801181724640896 - 228867929910118694 cannot be represented in type 'long int' Reproduced with -m32 on x86_64. Silly me. Will fix. pr80932.c:10:88: runtime error: signed integer overflow: -413853711 * -6 cannot be represented in type 'long int' Author: mpolacek Date: Thu Jun 8 12:38:27 2017 New Revision: 249010 URL: https://gcc.gnu.org/viewcvs?rev=249010&root=gcc&view=rev Log: PR sanitize/80932 * c-c++-common/ubsan/pr80932.c: Test with ints, not with long ints. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/c-c++-common/ubsan/pr80932.c Author: rguenth Date: Mon Aug 28 12:49:55 2017 New Revision: 251381 URL: https://gcc.gnu.org/viewcvs?rev=251381&root=gcc&view=rev Log: 2017-08-28 Richard Biener <rguenther@suse.de> Backport from mainline 2017-06-14 Richard Biener <rguenther@suse.de> PR middle-end/81088 * fold-const.c (split_tree): Drop TREE_OVERFLOW flag from literal constants. (fold_binary_loc): When associating do not treat pre-existing TREE_OVERFLOW on literal constants as a reason to allow TREE_OVERFLOW on associated literal constants. * c-c++-common/ubsan/pr81088.c: New testcase. 2017-06-13 Richard Biener <rguenther@suse.de> PR middle-end/81065 * fold-const.c (extract_muldiv_1): Remove bogus distribution case of C * (x * C2 + C3). (fold_addr_of_array_ref_difference): Properly fold index difference. * c-c++-common/ubsan/pr81065.c: New testcase. 2017-06-08 Marek Polacek <polacek@redhat.com> PR sanitize/80932 * c-c++-common/ubsan/pr80932.c: Test with ints, not with long ints. 2017-06-07 Marek Polacek <polacek@redhat.com> PR sanitizer/80932 * fold-const.c (extract_muldiv_1) <case MINUS_EXPR>: Add TYPE_OVERFLOW_WRAPS check. * c-c++-common/ubsan/pr80932.c: New test. Added: branches/gcc-7-branch/gcc/testsuite/c-c++-common/ubsan/pr80932.c branches/gcc-7-branch/gcc/testsuite/c-c++-common/ubsan/pr81065.c branches/gcc-7-branch/gcc/testsuite/c-c++-common/ubsan/pr81088.c Modified: branches/gcc-7-branch/gcc/ChangeLog branches/gcc-7-branch/gcc/fold-const.c branches/gcc-7-branch/gcc/testsuite/ChangeLog |