Skip to content

LGTM.com - cpp/incorrect-allocation-error-handling false positive with std::nothrow #6435

@Joshua-Anderson

Description

@Joshua-Anderson

Description of the false positive

Fprime is a C++ project targeting embedded systems and is explicitly calling the new(std::nothrow) variant of new.
Because of this, it must check that the return value of new(std::nothrow) is null. The cpp/incorrect-allocation-error-handling incorrectly suggests that the allocation cannot return null, despite the fact that it can. Suggesting the incorrect error handling of memory allocation is dangerous and can lead to serious bugs.

It looks like cpp/incorrect-allocation-error-handling query has logic for handling std::nothrow but isn't successfully matching these calls to new(std::nothrow).

https://lgtm.com/projects/g/nasa/fprime/rev/pr-47d3627dbb3106f32896b17edc48b8829d494566

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions