https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90196
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- The warning works as intended. Types with a non-trivial destructor do not cause a warning, because if the destructor has side effects then the variable is not unused. We don't want to warn for types like std::lock_guard which are constructed and then not "used", because the destructor does all the useful work.