Skip to content

Analyzer gets confused by decrementing loops #15169

@Florob

Description

@Florob
Bugzilla Link 14797
Resolution DUPLICATE
Resolved on Feb 22, 2013 18:57
Version trunk
OS Linux
CC @belkadan

Extended Description

Apparently the analyzers data flow analysis apparently gets confused by loops which count downwards. Below is a small testcase, which works fine when the first loop is changed to increment. As is the static analyzer claims uninitialized values in the second loop;

#include <assert.h>
void foo(int len)
{
int a[5], b;

assert((len > 0) && (len <= 5));

for (int i = len-1; i >= 0; i--)
	a[i] = 0;

for (int i = len-1; i >= 0; i--)
	b = a[i];

}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions