jpmugaas
(J. Peter Mugaas)
May 21, 2024, 1:38pm
1
Make sure to read this post before raising a thread here:
Hey SonarSource Community!
False-positives happen , as do false-negatives, and we’re eager to fix them. We are thrilled when our users report problems, so we can make our products better.
What is a false-positive (FP)?
A false-positive is when an issue is raised unexpectedly on code that should not trigger an issue, or where the suggested action doesn’t make any sense for the code.
What is a false-negative (FN)?
A false-negative is when an issue should be raised on a piece of code, but isn’t…
Then tell us:
What language is this for?
C++
cpp:S5008 Tags: based-on-misra cppcoreguidelines
The line reads:
Snippet
__declspec(nothrow) HRESULT __stdcall efxc2CompilerIncludes::CompilerIncludes::Open(D3D_INCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID* ppData, UINT* pBytes) {
Why do you believe it’s a false-positive/false-negative?
This is an overridden method as indicated by the header for that file and that header says:
Snippet
__declspec(nothrow) HRESULT __stdcall Open(D3D_INCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID* ppData, UINT* pBytes) override;
It did appear in SonarCloud and I marked it as “Acceptable for now” since I could not compile if I changed the LPVOID type.
SonarQube - which version?
N/A
SonarLint - which IDE/version?
SonarLint for Visual Studio 2022.
* in connected mode with SonarQube or SonarCloud?
How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
Hi @jpmugaas , and thanks for taking the time to share the feedback with us,
Just to make sure I understand the false positive you are describing. Could you confirm that the following example demonstrates it?
struct Base {
virtual ~Base() = default;
virtual void f(void* ptr);
};
struct Derived : Base {
void f(void* ptr) override;
};
void Derived::f(void* ptr) { // S5008 reported here, FP?
// ...
}
You can also check the behavior of the analyzer on this example on Compiler Explorer .
jpmugaas
(J. Peter Mugaas)
May 21, 2024, 6:04pm
5
Yes, it triggers the same behavior. The problem was that I was inheriting from an interface provided by the Win32 API so I can’t easily change void* to something else. The API is ID3DInclude (d3dcommon.h) - Win32 apps | Microsoft Learn .
marco.b
(Marco B)
May 22, 2024, 7:06am
9
Thank you, @jpmugaas , for sharing this feedback.
We are aware of this problem and track it under [CPP-2782] - Jira . However, please understand this is part of a larger and complex problem.
If you cannot change the header file, I think it would be acceptable to mark this issue as a False Positive.
Cheers