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: [email protected]
ReportedBy: [email protected]
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)