Skip to content

[clang] -Wunique-object-duplication in static class member functions, intentional? #131745

Open
@carlosgalvezp

Description

@carlosgalvezp

Hi,

We are getting hits of the -Wunique-object-duplication warning in this type of code:

struct Foo
{
    Foo& get()
    {
        static Foo f{};  // -Wunique-object-duplication
        return f;
    }
};

Example: https://godbolt.org/z/nhEj7rnbh

I did not see this use case in the unit tests, so I wonder if warning here is intentional?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions