What analysis options I need to catch the following c++ error.

Hi, what "inspection severity" I would need to enable to catch the following error ? 

Thanks.

class Test
{
public:
    Test(int i) : m_i(i)
    {
        std::cout << m_i << std::endl;
    };
    int m_i;
};

class MainTest
{
public:
    MainTest() : m_Test(i)  {}; // i is not initialized here... 

    Test m_Test; 
    int i = 33; // if I put this line before the line above it will be corrected.
};

int main()
{
    MainTest m;

    std::cout << "Hello World!\n"; 
}
2 comments
Comment actions Permalink

Hello,

There are two different checks which will warn you about this problem: ReSharper's "Object member might not be initialized" and clang-tidy's "uninitialized clang diagnostic".

Thanks!

0

Please sign in to leave a comment.