This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/53871] New: Please warn about endless loops if they are obvious
- From: "tim.ruehsen at gmx dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 06 Jul 2012 10:03:14 +0000
- Subject: [Bug c/53871] New: Please warn about endless loops if they are obvious
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53871
Bug #: 53871
Summary: Please warn about endless loops if they are obvious
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: tim.ruehsen@gmx.de
Obvious endless loops could be reported, e.g. if the loop condition doesn't
change and the loop can't be left otherwise.
Example:
// x is declared non-volatile
while (x!=0);
while (x!=0) {
a++;
}
An optional -Wendless-loop could detect such issues with all kind of loops.
splint 3.1.2 says about the above axamples:
Suspected infinite loop. No value used in loop test (a) is modified by test or
loop body.
This appears to be an infinite loop. Nothing in the body of the loop or the
loop test modifies the value of the loop test. Perhaps the specification of a
function called in the loop body is missing a modification. (Use -infloops to
inhibit warning)