Please provide
- Operating system: Ubuntu 20.04, Linux/GCC-9
- SonarLint plugin version: v4.8.0
- Programming language you’re coding in: C++
- Is connected mode used: No
And a thorough description of the problem / question:
SonarLint reported “1st function call argument is an uninitialized value [+4 locations] sonarlint(cpp:S836)” with this code snipset. But I think it is false positive warning.
// Function signature of ParseTuple: auto ParseTuple(const std::string& s) -> tl::expected<std::tuple<std::string, std::string, std::string>, Error>;
// tl::expected is open source implementation of std::expected.
// https://github.com/TartanLlama/expected
const auto default_value = std::make_tuple("lemon", "lime", "pomelo");
const auto& [x, y, z] = ParseTuple("(lemon,lime)").value_or(default_value);
const auto it = std::find_if(
tups.cbegin(), tups.cend(), // Type of tups is vector<tuple<string,string,string>>
[&x](const auto& t) { return x == std::get<0>(t); } // <-- sonarlint(cpp:S836)
);