LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 13426 - False positive: impossible path
Summary: False positive: impossible path
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Static Analyzer (show other bugs)
Version: 3.1
Hardware: PC FreeBSD
: P enhancement
Assignee: Denys Petrov
URL:
Keywords:
: 27674 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-07-20 22:40 PDT by Garrett Wollman
Modified: 2020-06-15 08:40 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Garrett Wollman 2012-07-20 22:40:11 PDT
When running the analyzer against OpenAFS git master, vlserver/vl_utils.c reports a false uninitialized argument as shown here: http://hergotha.csail.mit.edu/~analyzer/2012-07-20-1/report-8QtTSW.html#EndPath
If nextblockindex == blockindex is false (#3), then clearly the loop must execute at least once (#4), causing prevblockindex to be initialized (line 929).

clang version 3.1 (branches/release_31)
Target: amd64-portbld-freebsd8.3
Thread model: posix
Comment 1 Anna Zaks 2012-07-21 01:27:04 PDT
Reproducible with:

int foo(int y, int z) {
	int x;
	if (y == z) {
		x = 0;
	} else  {
		if (y != z) {
			x = 1;
		}
	}
	return x;
}

Cloned to radar://11928676
Comment 2 Erik Cederstrand 2012-10-01 03:33:19 PDT
Here's a similar one with less/greater:

int *test(int x, int y)
{
    int i;
    if (x >= y) {
        i = 0;
    } else {
        if (x < y) {
            i = 1;
        }   
    }   
    return i;
}


And with a while-loop instead:


int *test(int x, int y)
{
    int i;
    if (x >= y) {
        i = 0;
    }
    while (x < y) {
        i = 1;
        break;
    }
    return i;
}
Comment 3 Anna Zaks 2012-10-05 20:00:19 PDT
This could be addressed with alpha-renaming. Opened radar://12447480 for internal tracking.
Comment 4 Anna Zaks 2012-10-05 20:02:40 PDT
Actually, this is already tracked by radar://7670487
Comment 5 Devin Coughlin 2016-05-08 12:33:31 PDT
*** Bug 27674 has been marked as a duplicate of this bug. ***
Comment 6 Denys Petrov 2020-05-05 08:03:48 PDT
Confirmed. Proposed a fix https://reviews.llvm.org/D78933
Comment 7 Denys Petrov 2020-06-15 08:40:43 PDT
Fixed by https://reviews.llvm.org/D78933