-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tcling] Suppress -Wunused-result
diagnostics in wrappers generated by TClingCallFunc
#9244
Conversation
Starting build on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for finding this out it !
Would changing
to
also fix it? (I can't judge if that's a better or worse solution :) ) |
I think Enrico's solution might be slight better as it is a more local solution (and clarify the intent of the code). |
dd5fb59
to
2ea6e72
Compare
Starting build on |
-Wunused-result
diagnostics in wrappers generated by TClingCallFunc-Wunused-result
diagnostics in wrappers generated by TClingCallFunc
Yes, of course. Changed! Thanks for the suggestion, @eguiraud! |
Build failed on mac11.0/cxx17. Failing tests: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get a test for this, presumably in https://github.com/root-project/root/blob/master/core/metacling/test/TClingCallFuncTests.cxx
Build failed on windows10/cxx14. Warnings:
Failing tests: |
…y TClingCallFunc A TClingCallFunc wrapper function might look as the excerpt below, where the function denoted by `func` may have been annotated as `[[nodiscard]]`. Note that if `ret == nullptr` the result of the call is unused. ``` extern "C" void __cf_0(void* obj, int nargs, void** args, void* ret) { if (ret) { new (ret) (return_type) ((class_name*)obj)->func(args...); } else { ((class_name*)obj)->func(args...); } } ``` In turn, this triggers warnings when used by cppyy/PyROOT, e.g. ``` >>> import ROOT >>> v = ROOT.std.vector(int)() >>> v.empty() input_line_34:10:7: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result] ((const vector<int>*)obj)->empty(); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ True >>> ``` Given the above, the second call expression will be casted to `void`. Closes issue root-project#8622.
2ea6e72
to
6368084
Compare
Starting build on |
Build failed on ROOT-ubuntu16/nortcxxmod. Errors:
|
6368084
to
2e96179
Compare
Build failed on ROOT-debian10-i386/cxx14. Errors:
|
Starting build on |
Build failed on ROOT-ubuntu16/nortcxxmod. Errors:
|
Build failed on ROOT-ubuntu2004/soversion. Errors:
|
Build failed on ROOT-debian10-i386/cxx14. Errors:
|
Build failed on ROOT-performance-centos8-multicore/default. Errors:
|
2e96179
to
8993573
Compare
Starting build on |
Build failed on mac11.0/cxx17. Failing tests: |
Build failed on windows10/cxx14. Failing tests: |
8993573
to
bd11bfe
Compare
Starting build on |
bd11bfe
to
5dfb0c7
Compare
Starting build on |
Build failed on windows10/cxx14. Errors:
|
5dfb0c7
to
f216f65
Compare
Starting build on |
Build failed on mac11.0/cxx17. Failing tests: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm!
This pull-request suppresses
-Wunused-result
diagnostics for wrapper functions generated by TClingCallFunc (see below).A TClingCallFunc wrapper function might look as the excerpt below, where the function denoted by
func
may have been annotated as[[nodiscard]]
. Note that ifret == nullptr
the result of the call is unused.In turn, this triggers warnings when used by cppyy/PyROOT, e.g.
Changes or fixes:
-Wunused-result
diagnostics only for TClingCallFunc wrapper functions.Checklist:
This PR fixes #8622.
Sibling PR in roottest: root-project/roottest#791