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
 Bad suggestion on default constructor
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

DaveSwedensky
New Member

United Kingdom
7 Posts

Posted - Sep 13 2017 :  04:32:51 AM  Show Profile  Reply with Quote
I've found what looks like a bug in the "VA Code Inspection" suggestions, but would be happy to be proved wrong :)

Unfortunately I can't seem to find a good minimal example of my problem - I think it only arises in complexity. But it goes roughly like this:

struct A
{
    A(Arg1 arg1, Arg2 arg2) {}
};

struct B : public A
{
    B() : A(thing1, thing2) {}
};

All well and good. But if for some reason the inspector thinks the call to A's constructor is wrong, for example:

B() : A(thing1) {}

then the "Code Inspection" window will tell me that the "Default constructor body can be replaced with '= default'", and the fix becomes:

B() : A(thing1) = default;

which doesn't compile. Ok, for this example it wouldn't compile because we've got a bad constructor for A.

In my Real Life example, the constructor for A has a more complex form and the constructor for B does compile properly but for some reason the code inspector has the same problem so it suggests I change to:

B() : A(...args...) = default;

which is definitely wrong.

Apologies for not being able to give a self-contained example of this - I tried but when I simplified as soon as the parser understood the constructor line the problem went away.

There doesn't seem to be any way to tell the code inspector that a particular instance that it thinks is wrong can't be changed for some (hopefully good) reason. Some IDEs do this by allowing a special comment on the line before and allow this to be added instead of applying the quick fix - could such a feature be incorporated for VisualAssist?

Thanks,
-Dave

accord
Whole Tomato Software

United Kingdom
3036 Posts

Posted - Sep 13 2017 :  3:00:36 PM  Show Profile  Reply with Quote
We have a bug report for Code Inspections to not suggest constructor with initialiser list be replaced with = default

case=109725

Is it possible that your "real" world example has an initializer list?

Regarding a special comment to disable code inspections: I have put in a feature request for that.

case=111068
Go to Top of Page

DaveSwedensky
New Member

United Kingdom
7 Posts

Posted - Sep 14 2017 :  03:44:25 AM  Show Profile  Reply with Quote
Yes, it has an initializer list so is likely covered by the same bug. Interestingly I found some examples of use of initializer lists where the bug does not manifest. So long as the issue is logged, I'm happy. Also, thanks for the feature request. I think it will be useful for many people.

Apologies for a very basic question, but how do I subscribe to updates for these issues?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
14846 Posts

Posted - Sep 19 2017 :  09:09:34 AM  Show Profile  Reply with Quote
When we have a new release that fixes either of these cases, this thread will be updated.

The easiest method may simply be to turn On:

VA Options -> Startup -> Automatically check for new version

and review the release notes to see what has been fixed. You can also always ask here for an update on this.

zen is the art of being at one with the two'ness
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