[Bug c++/102335] New: gcc misses -Wunused-value
vanyacpp at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Sep 14 18:11:12 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102335
Bug ID: 102335
Summary: gcc misses -Wunused-value
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vanyacpp at gmail dot com
Target Milestone: ---
struct mytype
{
int memfun [[gnu::pure]] ();
};
void test()
{
mytype x;
x.memfun(); // -Wunused-value
mytype().memfun(); // no -Wunused-value
}
https://godbolt.org/z/vc49jWGqn
The code above contains two usages of a [[gnu::pure]] function with ignored
return value. GCC detect only the first one. I believe the second one deserves
a warning too.
Clang shows a warning on both usages.
More information about the Gcc-bugs
mailing list