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
 Find References confused
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jschroedl
Tomato Guru

USA
107 Posts

Posted - Nov 02 2006 :  12:08:09 PM  Show Profile  Reply with Quote
(Hi there, VAX 14-day trial newbie here so apolgies if this is old news; my search attempts didn't find anything related):

int foo;
void testFindReferences()
{
   foo = 3; // Find refs on me finds foo below, not above.

   int foo;
   foo = 4;
}


And doing a find references on the outer foo shows no refs, but on the inner foo it locates the int foo below it as a ref. Seems like a bug.

John

feline
Whole Tomato Software

United Kingdom
19024 Posts

Posted - Nov 02 2006 :  3:16:04 PM  Show Profile  Reply with Quote
That's a bug.

case=3414

Do you see this sort of thing often in your code? It has the potential to be very confusing!

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

jschroedl
Tomato Guru

USA
107 Posts

Posted - Nov 02 2006 :  8:12:10 PM  Show Profile  Reply with Quote
We do not see this often in the code. In fact, every case I've encountered has been a bug in our code and is always the result of a second developer inheriting the code and not realizing the earlier 'foo'. Default VS compiler warnings don't flag this though I'm attempting to move everyone to /W4 and/or /analyze builds.

I encountered this b/c I've been going through the PREfast (Team System Static Code Analysis) warnings report for our project. I was attempting to rename the inner foo to something different with the VA Rename refactoring when I noticed it marked the incorrect items. This made me a little wary of the Rename refactoring.

I agree, code of this nature should not be in the project as it can cause bugs.

I noticed a similar bug with the references picking up items from an earlier scope but did not create another test case -- I believe the earlier scope was in a case statement. Something like:

{
case 1:
{
int bar;
. . .
}

case 2:
{
int bar;

bar = 5; // I believe highlighting refs on this picked up bar from an earlier case as well.
}

I didn't isolate it to a repro test case but will keep an eye out for it.


John
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19024 Posts

Posted - Nov 03 2006 :  08:30:27 AM  Show Profile  Reply with Quote
A couple of tests on a switch statement, with brackets and local variables inside the two cases are not showing any problems.

If you run into this problem again any clues as to the cause would be appreciated.

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