A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/llvm/llvm-project/issues/54489 below:

-Wunused-variable triggers for temporaries with side effects when bound to a reference · Issue #54489 · llvm/llvm-project · GitHub

The following code warns on guard2 and guard3 (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.

struct RAIIWrapper {
    RAIIWrapper();
    ~RAIIWrapper();
};

void foo() {
    auto const  guard = RAIIWrapper();
    auto const& guard2 = RAIIWrapper(); //unused variable 'guard2'
    auto && guard3 = RAIIWrapper(); //unused variable 'guard3'
}

https://godbolt.org/z/zr7dsevoc


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4