Bug 56456 (Warray-bounds) - [meta-bug] bogus/missing -Warray-bounds
Summary: [meta-bug] bogus/missing -Warray-bounds
Status: NEW
Alias: Warray-bounds
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, meta-bug
Depends on: 35587 48558 56210 65461 67872 78678 81601 82581 82585 82608 84050 84863 85398 86223 86434 86611 86613 86691 86833 86889 87926 88565 88771 88921 89149 90238 90525 90753 91146 92110 92380 92381 92397 92539 92937 93514 93848 94580 94675 94985 95072 95463 95619 95635 96290 96346 96561 96900 96925 97047 97261 97410 97425 97429 97495 98483 99129 99140 99159 99418 99474 99475 99525 99532 99580 99630 99632 99635 100038 100137 100944 101397 101455 101525 101671 101679 102101 102513 102690 102731 103542 104017 104165 104355 104603 104965 105400 105420 105438 105679 105684 105690 105746 105823 105918 106247 106480 106762 107004 107677 107699 107754 107927 107986 108051 108082 108499 108770 109071 109290 109298 109590 109717 109727 109744 110283 110458 110498 110620 110645 110764 111035 111273 111374 111415 35392 35903 36902 38480 41847 44300 45180 45978 47418 48560 49657 52504 53198 53890 56273 59124 59377 61277 61957 63197 63441 63477 66974 69224 80202 80406 80907 81172 82286 82455 82583 82588 82596 82609 82612 83312 83510 83776 84047 84051 84053 84079 84859 85651 86341 86614 86650 86741 87072 87192 87742 88800 88992 89427 89550 89644 89720 90367 90376 90387 90752 90758 90806 91457 91462 91463 91535 91584 91647 91679 91830 92039 92144 92290 92323 92337 92341 92349 92363 92378 92622 92815 92828 92879 92936 93437 94195 94647 94940 95461 95988 96984 97391 98266 98503 99121 99578 100430 100451 101372 101436 101600 101977 102006 102151 102216 102346 102453 102630 102706 103215 103292 104966 105348 105523 105726 105762 106149 106446 106900 106901 106920 107852 108127 108217 108306 108768 108980
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-26 09:48 UTC by Jorn Wolfgang Rennecke
Modified: 2023-09-14 14:59 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-02-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jorn Wolfgang Rennecke 2013-02-26 09:48:13 UTC

    
Comment 1 Richard Biener 2013-02-26 10:18:08 UTC
Confirmed.  Thanks for adding this meta-bug ...

General note: most of these bugs are symptoms for missed VRP opportunities
(though sometimes very hard to unleash).
Comment 2 Mason 2017-10-12 20:09:01 UTC
A few more bugs should be added to this tracker:
(It seems I don't have permission to do that?)

bug 59124
bug 63441
bug 63477
bug 80907
bug 82286

Adding my own testcase here:

extern int array[3];
void foo(int n)
{
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < i; ++j)
			if (array[i] == array[j])
				array[j] = 0;
}

gcc -Wall -O3 test.c triggers bogus warning(s) with any version of gcc >= 4.8
Comment 3 Eric Gallager 2017-10-17 20:35:49 UTC
How essential is the "when inlining or unrolling" portion of the title for this bug? i.e., can it be used as a meta-bug for all -Warray-bounds issues? If not, how to tell if any given -Warray-bounds bug is related to inlining/unrolling or not?
Comment 4 rguenther@suse.de 2017-10-18 07:38:00 UTC
On Tue, 17 Oct 2017, egallager at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456
> 
> Eric Gallager <egallager at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |egallager at gcc dot gnu.org
> 
> --- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> --- How 
> essential is the "when inlining or unrolling" portion of the title for 
> this bug? i.e., can it be used as a meta-bug for all -Warray-bounds 
> issues? If not, how to tell if any given -Warray-bounds bug is related 
> to inlining/unrolling or not?

It's hard to tell.  Unless we have another meta-bug just re-use this one.
Comment 5 Mason 2017-10-18 09:12:39 UTC
Slightly smaller testcase, similar to bug 80907.

extern int M[16];
void foo(int n)
{
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < i; ++j)
			M[i+j] = 0;
}

$ gcc-7 -O3 -Wall -S testcase4.c 
testcase4.c: In function 'foo':
testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds]
    M[i+j] = 0;
    ~^~~~~
testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds]
testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds]
testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds]
testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds]
testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds]
testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds]
testcase4.c:6:5: warning: array subscript is above array bounds [-Warray-bounds]

Same result with trunk.

Using -fopt-info adds:
testcase4.c:5:3: note: loop turned into non-loop; it never loops.
testcase4.c:5:3: note: loop with 17 iterations completely unrolled
Comment 6 Eric Gallager 2017-10-18 09:45:36 UTC
(In reply to rguenther@suse.de from comment #4)
> 
> It's hard to tell.  Unless we have another meta-bug just re-use this one.

I couldn't find another one that looked relevant so I'll re-use this one.
Comment 7 Martin Sebor 2017-10-19 02:31:20 UTC
Now that this bug has become a tracker for both false positives and false negatives the inlining/unrolling part is not relevant anymore so adjusting the Summary.