Describe the bug
import ROOT
ROOT.gInterpreter.Declare(
"""
struct S{
std::vector<int> vec1;
};
""")
s = ROOT.S()
if (s.vec1.empty()):
print("s vec1 is empty")
$ python struct_with_vec_empty_nodiscard.py
input_line_38:10:7: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
((const vector<int>*)obj)->empty();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s vec1 is empty
Expected behavior
No warning triggered.
Setup
ROOT 6.25 built on Fedora34 with GCC 11
Additional context
This is the behaviour at the root prompt
root [0] std::vector<int> vec1;
root [1] vec1.empty()
ROOT_prompt_1:1:1: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
vec1.empty()
^~~~~~~~~~
(bool) true
root [2] if (vec1.empty()) {}