- Notifications
You must be signed in to change notification settings - Fork14.5k
Closed
Description
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'}