Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-287596: "Code is heuristically unreachable" doesn't consider variables passed by reference

$
0
0
Reporter Nathan Baulch (nathan_baulch) Nathan Baulch (nathan_baulch)
Created Jan 5, 2012 9:11:40 AM
Updated Jan 5, 2012 9:11:40 AM
Priority Normal
Type Bug
Fix versions No Fix versions
State Submitted
Assignee Evgeny Pasynkov (pasynkov)
Subsystem Code Analysis - Find Code Issues
Affected versions 6.1
Fixed in build No Fixed in build
The following example demonstrates a false positive for the "Code is heuristically unreachable" code issue.
Set a breakpoint on the highlighted line and it will be hit if anything other than a string is passed to the Convert method.
object Convert(object obj)
{
    var str = obj as string;
    if (str != null)
    {
        return str;
    }
    if (TryConvert(ref obj))
    {
        str = obj as string;
        if (str != null)
        {
            return str; // FALSE POSITIVE: "Code is heuristically unreachable"
        }
    }
    return null;
}
bool TryConvert(ref object obj)
{
    obj = "NOT NULL";
    return true;
}

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>