This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/80653] New: Enhancement: better location info for -Wunsafe-loop-optimizations
- From: "egall at gwmail dot gwu.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 06 May 2017 13:54:22 +0000
- Subject: [Bug c/80653] New: Enhancement: better location info for -Wunsafe-loop-optimizations
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80653
Bug ID: 80653
Summary: Enhancement: better location info for
-Wunsafe-loop-optimizations
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: egall at gwmail dot gwu.edu
Target Milestone: ---
Currently, with a for-loop, -Wunsafe-loop-optimizations points to the "for":
reloc.c: In function 'bfd_generic_get_relocated_section_contents':
reloc.c:6000:7: warning: missed loop optimization, the loop counter may
overflow [-Wunsafe-loop-optimizations]
for (parent = reloc_vector; (parent != NULL) && (*parent != NULL);
^~~
and with a while-loop, it points to the opening parenthesis:
pef.c: In function 'bfd_pef_parse_symbols':
pef.c:893:13: warning: missed loop optimization, the loop counter may overflow
[-Wunsafe-loop-optimizations]
while (((codepos + 4UL) <= codelen) && (codepos < (size_t)UINT_MAX))
^
pef.c:723:13: warning: missed loop optimization, the loop counter may overflow
[-Wunsafe-loop-optimizations]
while (((pos + 4UL) <= len) && (pos < (size_t)UINT_MAX))
^
It'd be more useful if the caret instead pointed to the variable being used as
the loop counter, and/or the point in the loop where it actually overflows