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
3287 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
18749 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

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Sep 26 2017 :  08:57:59 AM  Show Profile  Reply with Quote
You can also subscribe to this topic at the top of this page.
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Nov 07 2019 :  5:45:28 PM  Show Profile  Reply with Quote
case=111068 is implemented in build 2353
https://support.wholetomato.com/default.asp?W404#2353

Starting in 2353, directives in source comments can prevent issues from being flagged in particular instances without disabling a Code Inspection checker globally.

Directives that are processed before parsing:
// vaCI:skipall		skip Code Inspection entirely

Directives that are processed after parsing:
// vaCI:skip		skip fix(es) from the current line
// vaCI:skip+10		skip 10 lines, starting with current line
// vaCI:skip-10		skip 10 previous lines, starting with current line
// vaCI:skip+*		skip until the end
// vaCI:skip-*		skip from the beginning
// vaCI:<any skip>:checker,checker,...	
// 				skip only specified checker(s); 
// 				checker names are matched by given substring;
//				code issue names/descriptions are not matched;


An example that skips all modernize-make-unique and modernize-make-shared issues:

// vaCI:skipall:unique,shared

Edited by - sean on Nov 07 2019 7:09:43 PM
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000