Skip to content

LGTM.com - false positive in "Potentially uninitialized local variable" #4259

@olehermanse

Description

@olehermanse

Description of the false positive

I think this kind of pattern is not so unusual:

int res;
bool was_attempted = false;

if (...)
{
    res = SomeOperation();
    was_attempted = true;
}

if (...)
{
    res = SomeOperation();
    was_attempted = true;
}

if (was_attempted && res != 0)
{
    printf("Some error: %d\n", res);
}

This causes the LGTM to give a false positive alert - for all cases were was_attempted is true, res is initialized.

URL to the alert on the project page on LGTM.com

https://lgtm.com/projects/g/cfengine/core/snapshot/1e3d1567db2ff8d470d3473ba68d27e933c1a7ae/files/libpromises/cf3parse_logic.h?sort=name&dir=ASC&mode=heatmap#x26838ee62fa30f43:1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions