문제

I am currently working on a codebase that is built on a foundation of sand.

There are numerous classes in supposedly tested libraries that violate the "Rule of 3". Most declare a non-trivial destructor, but are missing either a copy constructor or assignment operator.

Are there any compiler flags (gcc) or static analysis tools that warn when a class violates the rule of 3?

Currently we are using Coverity with GCC version 4.4.

도움이 되었습니까?

해결책

Coverity has. We use version 6.5. There is a checker MISSING_COPY_OR_ASSIGN.

다른 팁

C++test from Parasoft (commercial tool) has a rule (MRM-40) that covers "copy and destroy consistently" that looks like it would help you. Basically it says if you define any of the copy constructor, copy assignment operator, or destructor, you might need to define one or both of the others.

More info at http://www.parasoft.com/jsp/products/cpptest.jsp

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top