Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Code inspection on constructor / destructor

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
TheWisp Posted - Apr 25 2017 : 6:20:47 PM
Version: 2212, VS2017

Bug1: On constructor without parameter, it sometimes suggests that it can be replaced with '= default', although base class or member initialization are necessary. This usually happens when the initializer list is complex, and VA cannot see through every initialization step.

Bug2: It suggests derived class destructor is "overriding function without 'override' specifier". Needless to say, derived destructor never 'overrides' base destructor.
4   L A T E S T    R E P L I E S    (Newest First)
sean Posted - Sep 26 2017 : 10:57:48 PM
case=103139 is implemented in build 2235
holedigger Posted - Apr 27 2017 : 12:58:21 PM
Have you installed the just-released build 2217? We have made some improvements to the "=default" check.

I have tried to recreate your example, but I'm not seeing any problems:

#include <memory>

class Test
{
public:
	Test() : mVal(0) { }
	Test(const Test& rhs) : mVal(rhs.mVal) { }
	Test(Test&& rhs) noexcept : mVal(rhs.mVal) { }
	Test& operator=(const Test& rhs) { mVal = rhs.mVal; }
	Test& operator=(Test&& rhs) noexcept { mVal = rhs.mVal; }
	~Test() {}

private:
	std::unique_ptr<int> mPtr;
	int mVal;
};

svenjo Posted - Apr 27 2017 : 07:52:48 AM
As I understand the codeinspection for adding =default to construtors: VA seems to inspect only the code of the constructors and no the members. That's not enough!

Example: add an unique_ptr as member variable. Copy all other members in the copy-ctor.
With explicit copy ctor: all other member get copied and the unique_ptr keeps pointing to null.
With default copy ctor: (suggested from VA) compile error

Code inspection needs a better understanding of the code before proposing such changes!
holedigger Posted - Apr 26 2017 : 12:30:44 PM
Bug1 should be fixed in the next build, coming soon.

I'm not sure there is consensus regarding Bug2 (see: https://github.com/isocpp/CppCoreGuidelines/issues/721 and https://github.com/isocpp/CppCoreGuidelines/issues/832). I think we need an option to configure the behavior. (case=103139)

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000