On Tue, 3 Sep 2024 06:16:06 GMT, David Holmes <dhol...@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