SonarQube/SonarLint is incorrectly reporting cpp:S3519 (Returned pointer value points outside the original object (potential buffer overflow)) when using std::sort with MSVC (Visual C++ 2022). Easy to reproduce with the simplest example:
#include <string>
#include <vector>
#include <algorithm>
struct S // S3519 raised here
{
std::string a;
};
int main(int argc, char* argv[])
{
auto v = std::vector<S>{};
v.emplace_back("A");
std::sort(v.begin(), v.end(), [](const S& lhs, const S& rhs) { return lhs.a < rhs.a; });
}
Using SonarQube Enterprise 9.9.7