johnthagen / johnthagen/clion-cppcheck

Multiple warnings on same line might not be shown

Open
#37 11 comments 0 reactions 0 assignees View on GitHub
bug upstream
Dominant language
Java
Stars
35
Forks
6
PR merge metrics
No merged PRs in 30d

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

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.

![image](https://user-images.githubusercontent.com/242857/79689549-e855f580-8255-11ea-9e01-f158bb7d8d57.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.