Skip to content

-Wreturn-stack-address false negative #141906

Open
@JVApen

Description

@JVApen
#include <tuple>
#include <iostream>

struct A {
    int i;
};

auto getA(int i) -> const A& {
    std::tuple<A> tuple = std::make_tuple<A>(A{i});
    return std::get<A>(tuple);
}

int main() {
    std::cout << getA(9).i;
}

Code on compiler-explorer

MSVC does report a warning here: warning C4172: returning address of local variable or temporary : tuple

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerfalse-negative

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions