C++ Member variables should be initialized rule does not detect bug

We use SonarQube 9.9 LTS in developer edition. SonarQube is deployed with a Docker container.
My problem is that the rule S2107 “Member variables should be initialized” does not detect simple introduced bug in a C++ class.

class MyClass
MyClass() : m_myFirstMember(false) {}
bool myMethod() { if(m_mySecondMember) return true; }

bool m_myFirstMember;
bool m_mySecondMember;

In this example it detects the code smell “Do not use the constructor’s initializer list for data member m_myFirstMember. Use the in-class initializer instead.” but does not detect the member variable m_mySecondMember which is not initialized and is a very critical issue. Is there any reason ? Something is missing in my configuration ? Rule S2107 seems to be activated in the quality profile “Sonar way”

Thanks for your help

Sorry for my late reply.

I don’t think you are doing anything wrong @JorisL.
This must be an issue on our side.

I created the CPP-4175 ticket for tracking this significant false-negative case.

In the meantime, I’d suggest listening to the S3230 rule about promoting the use of in-class initializers, which might help to spot uninitialized variables by looking at their declarations. Unfortunately, this is the most I can help you with this one.

Thank you for raising this.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.