RFR: 8263718: unused-result warning happens at os_linux.cpp

Yasumasa Suenaga ysuenaga at openjdk.java.net
Wed Mar 17 23:11:49 UTC 2021


On Wed, 17 Mar 2021 16:46:13 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

> "Note that a logical negation prior to cast to void is sufficient to suppress the warning:
> 
> ```
>   int void_cast_should_not_warn() {
>      (void) !foo();
>      //     ^-- here
>      return 0;
>   }
> ```
> 
> "

The warning has gone with `(void)!`, but isn't is strange a bit? IMHO code changes or pragma (or compiler option) are suitable than it.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3042


More information about the hotspot-dev mailing list