https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121368
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC warns about both lines since GCC 7:
```
<source>: In function 'int main()':
<source>:8:13: warning: ignoring returned value of type 'S', declared with
attribute nodiscard [-Wunused-result]
test_fun()(); // No warning
~~~~~~~~^~
<source>:4:22: note: 'S' declared here
struct [[nodiscard]] S {};
^
<source>:9:27: warning: ignoring returned value of type 'S', declared with
attribute nodiscard [-Wunused-result]
std::bind(test_fun())(); // Emits warning: discarding nodiscard return
^
In file included from <source>:2:0:
/opt/compiler-explorer/gcc-7.1.0/include/c++/7.1.0/functional:541:2: note: in
call to '_Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...)
[with _Args = {}; _Result = S; _Functor = S (*)(); _Bound_args = {}]', declared
here
operator()(_Args&&... __args)
^~~~~~~~
<source>:4:22: note: 'S' declared here
struct [[nodiscard]] S {};
^
```
Now clang does not but this is not the place to report clang bug reports.