Skip to content

Conditional allocations shouldn't fail if cond=false, size=0 -> nullptr result #7255

@steven-johnson

Description

@steven-johnson

Allocations can be conditional; if the condition evaluates to false, we end up calling halide_malloc(0). Since it's legal via spec for malloc(0) to return nullptr, we need to be cautious here: if we are compiling with assertions enabled, and have a malloc() (etc) implementation that returns nullptr for alloc(0), we need to skip the assertion check, since we know the result won't be used... but the assertion would fail because the (ignored) result is null.

NOTE: I've only seen this in the C++ backend; so far, I can't replicate it with LLVM backends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions