Skip to content

out parameter diagnostics affect uninitialized variables at the _call site_ #5093

Closed
@MarijnS95

Description

@MarijnS95

A recent PR to prevent leaving out parameters uninitialized in function calls (#5047) seems to have escaped its cage and is now also disallowing uninitialized arguments into functions with out paramameters. See for example this (IMO totally valid) Interlocked* invocation:

        uint original;
        buffer.InterlockedAdd(offset, value, original);
        return original;
bindless.hlsl:110:46: error: variable 'original' is uninitialized when used here [-Werror,-Wuninitialized]
        buffer.InterlockedAdd(offset, value, original);
                                             ^~~~~~~~
bindless.hlsl:109:22: note: initialize the variable 'original' to silence this warning
        uint original;
                     ^
                      = 0

(Compiler from 667fb77)

I thought the whole point of out parameters and by extension this diagnostic is to know and force that the function will initialize original here, and it should thus not need to be pre-initialized by the caller.

Originally posted by @MarijnS95 in #5047 (comment), cc @llvm-beanz

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