Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Code inspection on constructor / destructor
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

TheWisp
New Member

5 Posts

Posted - Apr 25 2017 :  6:20:47 PM  Show Profile  Reply with Quote
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.

Edited by - TheWisp on Apr 25 2017 7:48:29 PM

holedigger
Whole Tomato Software

145 Posts

Posted - Apr 26 2017 :  12:30:44 PM  Show Profile  Visit holedigger's Homepage  Reply with Quote
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)

Whole Tomato Software
Go to Top of Page

svenjo
Starting Member

1 Posts

Posted - Apr 27 2017 :  07:52:48 AM  Show Profile  Reply with Quote
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!
Go to Top of Page

holedigger
Whole Tomato Software

145 Posts

Posted - Apr 27 2017 :  12:58:21 PM  Show Profile  Visit holedigger's Homepage  Reply with Quote
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;
};


Whole Tomato Software
Go to Top of Page

sean
Whole Tomato Software

USA
2399 Posts

Posted - Sep 26 2017 :  10:57:48 PM  Show Profile  Visit sean's Homepage  Reply with Quote
case=103139 is implemented in build 2235
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2017 Whole Tomato Software, Inc Go To Top Of Page
Snitz Forums 2000