https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100666
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |7.5.0, 8.3.0, 9.2.0
Ever confirmed|0 |1
Last reconfirmed| |2021-05-19
Known to fail| |10.1.0, 11.1.0, 12.0,
| |8.4.0, 9.3.0
Status|UNCONFIRMED |NEW
CC| |jakub at gcc dot gnu.org
Summary|warning: ignoring return |[9/10/11/12 Regression]
|value of 'constexpr _Tp&& |warning: ignoring return
|std::forward(typename |value of 'constexpr _Tp&&
|std::remove_reference<_Tp>: |std::forward(typename
|:type&) [with _Tp = |std::remove_reference<_Tp>:
|std::nullptr_t; typename |:type&) [with _Tp =
|std::remove_reference<_Tp>: |std::nullptr_t; ...]',
|:type = std::nullptr_t]', |declared with attribute
|declared with attribute |'nodiscard'
|'nodiscard' |[-Wunused-result]
|[-Wunused-result] |
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Mike Hommey from comment #0)
> (Note I'm not entirely sure this is a GCC bug, but it doesn't happen with
> GCC < 11 and with clang)
Yeah, this shouldn't warn.
Reduced:
[[nodiscard]] decltype(nullptr) null();
extern void foo(...);
void qux() {
foo(null());
}
GCC 10 has the same warning, it's just that std::forward didn't have the
[[nodiscard]] attribute.
It only happens when a nodiscard function returns std::nullptr_t and it's
passed to an ellipsis. GCC 7 was OK, and 8.3 and 9.2
It started with r279680:
re PR c++/92992 (Side-effects dropped when decltype(nullptr) typed
expression is passed to ellipsis)
PR c++/92992
* call.c (convert_arg_to_ellipsis): For decltype(nullptr) arguments
that have side-effects use cp_build_compound_expr.
* g++.dg/cpp0x/nullptr45.C: New test.