https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95454
Eric Estievenart <steve+gcc at tecwec dot eu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |steve+gcc at tecwec dot eu --- Comment #1 from Eric Estievenart <steve+gcc at tecwec dot eu> --- Indeed, confirming with even simpler code ( https://godbolt.org/z/EPbsfxYcj ): struct [[nodiscard]] Z {}; void f() { Z{}; // should warn but does not } Tested all versions: 11.2, trunk, with -Wall -Wextra -.... This is really a need for modern code, even experienced developpers sometimes forget the 'lock' in Lock lock{&mutex}; and this has severe consequences ;-)