[Bug libstdc++/109941] [feat req] Add an option to mark STL types as nodiscard
roi.jacobson1 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue May 23 13:31:45 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109941
--- Comment #4 from Roy Jacobson <roi.jacobson1 at gmail dot com> ---
The linked bug is about nodiscard applied to the class together with ignoring
temporary objects. But GCC will when the type is the return value or when the
nodiscard is applied to the constructor:
class [[nodiscard]] err {};
err f();
void g() {
f(); // Warning emitted
}
struct RAII {
[[nodiscard]] RAII(int x);
};
void h() {
RAII(0); // Warning emitted
}
More information about the Gcc-bugs
mailing list