Skip to content

-Wunused fails to realize copy initialization might have side effects #79518

@cor3ntin

Description

@cor3ntin

Compiling with -Wunused-variable, we expect no warning to be emitted (constructor calls might have side effects), yet a warning is emitted for s2

struct S {
    S(int);
};

int main() {
    S s(0); // no warning
    S s2 = 0; // unused
    S s3{0}; // no warning
}

https://godbolt.org/z/6zzfE9c4a

Metadata

Metadata

Assignees

Labels

c++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partygood first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions