Closed as duplicate of#131410
Closed as duplicate of#131410
Description
This code:
#include <utility>
struct A {
[[nodiscard]] static auto f() {
return 42;
}
};
template <typename T>
auto f(T &&t) {
return std::forward<T>(t).f();
}
auto b = f(A{}) == 42;
https://godbolt.org/z/cxGvxM9bn
Provokes a warning:
<source>:11:12: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
11 | return std::forward<T>(t).f();
| ^~~~~~~~~~~~~~~ ~
<source>:14:10: note: in instantiation of function template specialization 'f<A>' requested here
14 | auto b = f(A{}) == 42;
| ^
1 warning generated.
This seems to be a regression from clang-19.
This happens when:
- the function called is
static
- we are calling it through member syntax with an object that is
std::forward
-ed