Summary: | incorrect "array subscript is below/above array bounds" diagnostic | ||
---|---|---|---|
Product: | gcc | Reporter: | Robert Schiele <rschiele> |
Component: | middle-end | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED WORKSFORME | ||
Severity: | minor | CC: | jakub, msebor |
Priority: | P3 | Keywords: | diagnostic |
Version: | 5.0 | ||
Target Milestone: | --- | ||
See Also: | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63477 | ||
Host: | Target: | ||
Build: | Known to work: | 5.4.0, 6.4.0, 7.1.0, 8.0 | |
Known to fail: | Last reconfirmed: | ||
Bug Depends on: | |||
Bug Blocks: | 56456 |
Description
Robert Schiele
2014-10-02 10:31:19 UTC
I think it is just fine to diagnose this. I still see the warning with today's top of trunk (GCC 4.8) but I agree that some sort of a diagnostic here seems helpful. It would be nice if the warning could distinguish between cases where the index definitely is out of bounds and those where it could be but it's not 100% certain. I haven't looked at the implementation to see if this is feasible. It would also be helpful to have clarity (both for users and GCC developers) on what diagnostics are meant to be issued under what circumstances. Based on some other warnings (-Wuninitialized and -Wmaybe-uninitialized) it seems reasonable to expect -Warray-bounds to only be issued when an index is definitely out of bounds (and not when it could be). Just like with pr63477, I cannot reproduce the warning with this test case in GCC 8.0 anymore (despite what I said in comment #2), or 7-branch, or 6-branch, or even 5-branch. Just like in pr63477, bisection also points to r220157 (gcc 5.0.0) as the fix. So I'll assume that what I saw in comment #2 was some transient fluke and resolve this as worksforsome (based on comment #1 and #2 saying it would make sense to diagnose this). |