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
 local variable can be a constant reference
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

azur
Ketchup Master

Germany
52 Posts

Posted - Jan 04 2022 :  07:24:55 AM  Show Profile  Reply with Quote
The following code produce a false positive

if (true)
{
  CString text = "something";
  text.Insert(4, "xxx");
  ...
}


VA_X.dll file version 10.9.2440.0 built 2021.11.17
DevEnv.exe version 16.11.32002.261 Enterprise

feline
Whole Tomato Software

United Kingdom
18750 Posts

Posted - Jan 04 2022 :  1:31:50 PM  Show Profile  Reply with Quote
Can you please try this simple test function, and see what, if anything, Code Inspection picks up in this function:

void testCodeInspectFalsePositive()
{
	int* pTestPtr = 0; // this is being flagged by code inspection, to double check its active
	if (true)
	{
		CString text = "something";
		text.Insert(4, _T("xxx"));
	}
}

for me, only the comment marked line is being picked up. Hopefully you will see the same result.

I suspect I will need a more complete example to reproduce the problem you are seeing.

At the risk of asking a silly question, does your code currently compile? I only ask since if the code is currently invalid, since you are still writing it, this might be a factor in why you are getting the false positive.

zen is the art of being at one with the two'ness
Go to Top of Page

azur
Ketchup Master

Germany
52 Posts

Posted - Jan 05 2022 :  08:58:29 AM  Show Profile  Reply with Quote
Thank you for working on this issue.

I apologize for the previous code sample.
With the following sample I can safely reproduce the issue.

CString activeSupport(const CString& i_zText)
{
   bool support = "feline" == i_zText;
   if (support)
   {
      CString zText(i_zText);
      zText.Insert(0, '�');
      return zText;
   }

   return i_zText;
}

If I change '�' to '_' or "support:" then everthing is fine.
It's seems that characters above '~' 0x7E lead to the false positive. (I have checked some).

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18750 Posts

Posted - Jan 05 2022 :  11:42:47 AM  Show Profile  Reply with Quote
The first example was enough to get us started, it just didn't produce the problem in isolation, but it tends to take time to produce a small example, so that's fine. I am seeing the problem now, and looking into it.

zen is the art of being at one with the two'ness
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18750 Posts

Posted - Jan 05 2022 :  11:58:05 AM  Show Profile  Reply with Quote
How is the source code file with this character encoded? Is it "plain text" or some form of Unicode encoding? Visual Studio and Windows in general seems quite happy with this character in a plain text file, but it seems to be wrong, if you are strict about encoding and character codes. Currently trying to work out if this is a factor or not.

zen is the art of being at one with the two'ness
Go to Top of Page

azur
Ketchup Master

Germany
52 Posts

Posted - Jan 05 2022 :  12:26:53 PM  Show Profile  Reply with Quote
its "plain text" and the Option "Character Set" = "not set" (DevStudio 2019)
In a newer project (DevStudio 2022) with also "plain text"-File but the Option "Character Set" = "Use Unicode Character Set" I must change to
Text.Insert(0, _T('�'));
but then there is no false positive.

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18750 Posts

Posted - Jan 06 2022 :  12:27:56 PM  Show Profile  Reply with Quote
I have put in a bug report for this false positive:

case=147627

the change to the encoding and wrapping this in _T() having an effect is interesting, and supports the idea that this bug is related to the fact that this is a non standard ascii character.

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:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000