RFR: 8339364: AIX build fails: various unused variable and function warnings [v2]
Julian Waters
jwaters at openjdk.org
Tue Sep 3 06:45:18 UTC 2024
On Tue, 3 Sep 2024 06:16:06 GMT, David Holmes <dholmes at openjdk.org> wrote:
>>> Also doesn't a call like this trigger the warning about ignoring a function result, or have we disabled that one?
>>
>> Such a warning would be horrible to have enable. Then you would have to read the value of every function that thought it should return a value, even if it was just intended as some additional information that perhaps not everyone wanted to use. (And then you could not just store it into a variable and ignore it, since that would trigger the "unused variable" warning! ;-))
>>
>> I know IntelliJ can provide warnings when ignoring the return value of a few select JDK methods that are often used incorrectly, but then they had to annotate these specially. I don't know if there is any similar kind of annotation for clang/gcc that can warn about ignoring return values that really, really shouldn't be ignored, but I'd guess not.
>
> At one stage we started using the idiom:
>
> (void) someFunc();
>
> to tell the compiler to not warn about the unused result. IIRC that stopped working.
Not entirely sure about clang, but casting to void to silence warnings should still work for gcc
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20812#discussion_r1741510831
More information about the build-dev
mailing list