-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Environment
- Operating System (e.g. Ubuntu 16.04 x64): Windows 10 Version 1909
- IDE Version (e.g. CLion 2016.3.2): Clion 2020.1
- Cppcheck executable version (
cppcheck --version): 1.90 - Cppcheck plugin version: 1.4.2
- Exact strings used in cppcheck plugin options:
- cppcheck options: --enable=all --inconclusive --language=c++
Steps to reproduce the behaviour
This code
#include <iostream>
class A
{
public:
A():m_pi(new int[12]){}
~A(){throw "~A() dtor;";delete [] m_pi;}
private:
int *m_pi;
};
Produces four warnings
/mnt/s/GitHub/cppcheck-fw/lib/__test.cpp:6:6: warning: Class 'A' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor]
A():m_pi(new int[12]){}
^
/mnt/s/GitHub/cppcheck-fw/lib/__test.cpp:6:6: warning: Class 'A' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq]
A():m_pi(new int[12]){}
^
/mnt/s/GitHub/cppcheck-fw/lib/__test.cpp:7:7: warning: Class A is not safe, destructor throws exception [exceptThrowInDestructor]
~A(){throw "~A() dtor;";delete [] m_pi;}
^
/mnt/s/GitHub/cppcheck-fw/lib/__test.cpp:7:26: style: Statements following return, break, continue, goto or throw will never be executed. [unreachableCode]
~A(){throw "~A() dtor;";delete [] m_pi;}
^
The warnings on line 6 will both be shown, but line 7 omits the style one.
