Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

-Wunused-variable triggers for temporaries with side effects when bound to a reference #54489

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

Description

@cor3ntin

The following code warns onguard2 andguard3 (but not guard) despite all 3 variable having side effects on destruction.
This feels inconsistent and surprising.
GCC emits no warning in any of these cases.

structRAIIWrapper {RAIIWrapper();~RAIIWrapper();};voidfoo() {autoconst  guard =RAIIWrapper();autoconst& guard2 =RAIIWrapper();//unused variable 'guard2'auto && guard3 =RAIIWrapper();//unused variable 'guard3'}

https://godbolt.org/z/zr7dsevoc

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp