Abhishek Chennaka has submitted this change and it was merged. ( 
http://gerrit.cloudera.org:8080/22763 )

Change subject: [cmake] add -Werror=unused-result flag
......................................................................

[cmake] add -Werror=unused-result flag

This is to help catching issues with improper handling of return values
from functions declared 'nodiscard' or functions/methods returning
an enumeration or class declared 'nodiscard' by value when called
from a discarded-value expression other than a cast to void [1].
This should also help catching similar issues with functions/methods
marked with the WARN_UNUSED_RESULT macro, i.e. pre-C++17 style
declarations.

In particular, once this flag is added, any call to a function/method
that returns Status in a discarded-value expression other than a cast
to void will produce an error like below from CLANG and GCC compilers
of contemporary versions:

  CLANG:
    error: ignoring return value of function declared with 'nodiscard' 
attribute [-Werror,-Wunused-result]

  GCC:
    error: ignoring returned value of type ‘kudu::Status’, declared with 
attribute ‘nodiscard’ [-Werror=unused-result]

At least, it works with CLANG 11+ and GCC 13+ since the Status class
has been declared as 'nodiscard' in one of the prior changelists [2].

[1] https://en.cppreference.com/w/cpp/language/attributes/nodiscard
[2] https://github.com/apache/kudu/commit/8f136bb21

Change-Id: Ib5dd2df4784ba70162ecc0212b3791a5d9a13e5e
Reviewed-on: http://gerrit.cloudera.org:8080/22741
Tested-by: Alexey Serbin <[email protected]>
Reviewed-by: Yifan Zhang <[email protected]>
(cherry picked from commit ef7483f784911bcfdefba3c1a0068e26f6c3dbcb)
Reviewed-on: http://gerrit.cloudera.org:8080/22763
Reviewed-by: Abhishek Chennaka <[email protected]>
---
M CMakeLists.txt
1 file changed, 6 insertions(+), 0 deletions(-)

Approvals:
  Alexey Serbin: Verified
  Abhishek Chennaka: Looks good to me, approved

--
To view, visit http://gerrit.cloudera.org:8080/22763
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: branch-1.18.x
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib5dd2df4784ba70162ecc0212b3791a5d9a13e5e
Gerrit-Change-Number: 22763
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Abhishek Chennaka <[email protected]>
Gerrit-Reviewer: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Kudu Jenkins (120)

Reply via email to