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
 1525: Details to smart-ptr problems
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

o2a
Junior Member

24 Posts

Posted - Jun 26 2006 :  5:47:08 PM  Show Profile  Reply with Quote
Hi again,

I did some more research, why smart pointers don't work for me with VAX so often.
(Btw, history for build 1525 states that "case 4801" in context of std::string is fixed and links to my previously reported std::auto_ptr problem; but that one doesn't seem to be fixed yet. Just for the record. ;)


template <typename InnerType> class PtrTest
{
public:
	InnerType* ptr;
	InnerType* operator->()	{return ptr;}
};

struct Test1
{
	int someVar;
};

namespace TestNameSpace
{
	struct Test2
	{
		int someOtherVar;
	};
}

int main()
{
	PtrTest<Test1> test1;
	test1->|;	// correctly suggests 'someVar'

	PtrTest<::Test1> test1_2;
	test1_2->|;	// doesn't suggest anything

	PtrTest<::TestNameSpace::Test2> test2;
	test2->|;	// doesn't suggest anything

	using ::TestNameSpace::Test2;
	PtrTest<Test2> test2_2;
	test2_2->|;	// correctly suggests 'someOtherVar'

	typedef ::TestNameSpace::Test2 Test2_3;
	PtrTest<Test2_3> test2_3;
	test2_3->|;	// doesn't suggest anything

	typedef Test1 Test1_3;
	PtrTest<Test1_3> test1_3;
	test1_3->|;	// doesn't suggest anything
}


Obviously VAX gets confused when the inner type of a smart pointer is qualified with the scope-resolution operator in any way (note that even ::Test1 doesn't work, while Test2 without qualification (after using...) works).

Furthermore it fails, if the inner type is typedef'ed.

I didn't check yet, if this problem is more general or just related to smart pointers respectively overloaded operator->().

On a side note: Autocomplete (Ctrl-Space) doesn't seem to suggest any template parameters (e.g. InnerType when you are inside class PtrTest ). I don't know if this has been reported already - but I'd guess so.

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Jun 27 2006 :  6:04:41 PM  Show Profile  Reply with Quote
quote:
Originally posted by o2a

(Btw, history for build 1525 states that "case 4801" in context of std::string is fixed and links to my previously reported std::auto_ptr problem; but that one doesn't seem to be fixed yet. Just for the record. ;)


that came from me, i remember this. i was not able to reproduce what you reported, but i was able to reproduce something that looked identical to the std::string problem, so they got linked together.

lets see how i get on this time.

right, before i go raising any cases, lets see if we are seeing the same things.

i am using VS2003 and VA 1525, with content from default intellisense turned off.

test1 = typing -> produces a completion listbox automatically, with just the item "someVar"

test1_2 = typing -> does not produce anything, but pressing CTRL-SPACE produces a completion listbox with just the item "someVar". if i accept this suggestion then "someVar" is underlined as a mistyped symbol.

test2 = typing -> does not produce anything, and pressing CTRL-SPACE simply makes the IDE beep, no completion listbox.

type someOtherVar and it is underlined as a mistyped symbol.


test2_2 = typing -> produces a completion listbox automatically, with just the item "someOtherVar"


test2_3 = typing -> does not produce anything, but pressing CTRL-SPACE produces a completion listbox with just the item "someOtherVar". if i accept this suggestion then everything is fine, no underlining at all.


test1_3 = typing -> does not produce anything, but pressing CTRL-SPACE produces a completion listbox with just the item "someVar". if i accept this suggestion then everything is fine, no underlining at all.


how close is this to what you are seeing?

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

o2a
Junior Member

24 Posts

Posted - Jun 27 2006 :  6:56:00 PM  Show Profile  Reply with Quote
quote:

Originally posted by feline
right, before i go raising any cases, lets see if we are seeing the same things.

i am using VS2003 and VA 1525, with content from default intellisense turned off.


So far the same here, but VS2005 and spell checking is turned off (too many false alerts here ;)

quote:

test1 = typing -> produces a completion listbox automatically, with just the item "someVar"


Confirmed.

quote:

test1_2 = typing -> does not produce anything, but pressing CTRL-SPACE produces a completion listbox with just the item "someVar". if i accept this suggestion then "someVar" is underlined as a mistyped symbol.


I don't get a completion listbox. Could it be, that VAX just guessed the someVar from the above line? Would explain why it is still underlined. (But then again, I have the related option enabled and don't get any listbox here. Hmm.)

quote:

test2 = typing -> does not produce anything, and pressing CTRL-SPACE simply makes the IDE beep, no completion listbox.

type someOtherVar and it is underlined as a mistyped symbol.



Same here. (someOtherVar isn't recognized as a member in the "context" nor in the "definition" field of VAX)

quote:

test2_2 = typing -> produces a completion listbox automatically, with just the item "someOtherVar"



Confirmed.

quote:

test2_3 = typing -> does not produce anything, but pressing CTRL-SPACE produces a completion listbox with just the item "someOtherVar". if i accept this suggestion then everything is fine, no underlining at all.



Can't confirm. Interesting. =)
For me it's exactly the same behaviour as with test2.

quote:

test1_3 = typing -> does not produce anything, but pressing CTRL-SPACE produces a completion listbox with just the item "someVar". if i accept this suggestion then everything is fine, no underlining at all.



Can't confirm. Same as test2_3 here. (i.e. even if I add someVar manually here, it is not recognized by VAX) Hmm.

I tried it again with VS2003 this time - but got exactly the same result.
May be interesting:
If I add a dot instead of -> at the last place (test1_3) and try Ctrl-Space, I get the following:
test1_3.operator ->
Apart from the fact that this is not really correct, I actually get a completion listbox when I do a Ctrl-Space behind that, containing the correct member var.

If I do the same at the second to last place (test2_3) then at first the same "operator ->" is added - but Ctrl-Space doesn't open a completion list box then.

*shrug* :-}
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Jun 28 2006 :  12:58:35 PM  Show Profile  Reply with Quote
Thanks for the detailed example. All of the above cases should be fixed in 1526.
Go to Top of Page

o2a
Junior Member

24 Posts

Posted - Jun 29 2006 :  2:29:29 PM  Show Profile  Reply with Quote
quote:
Originally posted by support

Thanks for the detailed example. All of the above cases should be fixed in 1526.



Ah, you are getting closer with each build. :) Thanks for your work. But... just not completely fixed.

While the first test case indeed works with 1526, my actual project still has the old problems. (Even after rebuilding symbols db and clearing caches.)

So some more testing - more fun with namespaces and "smart pointers"

Result: VAX 1526 still has (nearly) the same problems, when the identifier, which is used in the smart pointer, is defined inside nested namespaces (tested with a depth of 2 only).

In the test case below, there are two classes with the same name (Test2) inside two different namespaces. This is not the cause of the actual problem here. If you rename one of them, you get nearly the same results - only the very last problem (test5) will be gone.

Another (minor) problem is, that VAX tries to recognize incorrectly qualified identifiers (the two test1-cases below). I'm not sure, if this could lead to some more serious problems - but most probably this is connected to the one mentioned above (test5).


template <typename InnerType> class PtrTest
{
public:
	InnerType* ptr;
	InnerType* operator->()	{return ptr;}
};


/////////////////////////////////////////////////////////////////////////////////////////
// code in one namespace using class from another namespace, both in global scope
namespace TestSpace
{
	struct Test2
	{
		int someOtherVar;
	};
}

namespace OtherSpace1
{
	void test()
	{
		// 'Test2' insufficiently qualified
		// - should be 'TestSpace::Test2' actually, but VAX still recognizes it
		PtrTest<Test2> test1;
		test1->|;	// works (incorrectly actually)
		// (suggests 'someOtherVar')

		// 'TestSpace::Test2' correctly qualified
		PtrTest<TestSpace::Test2> test2;
		test2->|;	// works (suggests 'someOtherVar')
	}
}


//////////////////////////////////////////////////////
// same as above, but now the class is in a namespace 
// being a child of the code's namespace
namespace OuterSpace
{
	////////////////////////////////////////////////
	namespace InnerSpace1
	{
		struct Test2
		{
			int innerVar;
		};
	}

	////////////////////////////////////////////////
	void testOuter()
	{
		// 'Test2' insufficiently qualified
		// but VAX recognizes ONE of the 'Test2'-classes here
		PtrTest<Test2> test1;
		test1->|;	// VAX assumes '::TestSpace::Test2'
		// (suggests 'someOtherVar')

		// '::TestSpace::Test2' correctly qualified
		// (without explicit global scope qualifier)
		PtrTest<TestSpace::Test2> test2;
		test2->|;	// works (suggests 'someOtherVar')

		// '::TestSpace::Test2' correctly qualified 
		// (with explicit global scope qualifier)
		PtrTest<::TestSpace::Test2> test3;
		test3->|;	// works (suggests 'someOtherVar')

		// 'InnerSpace1::Test2' locally qualified
		PtrTest<InnerSpace1::Test2> test4;
		test4->|;	// DOESN'T WORK 
		// (old behaviour -> no suggestion list box at all)

		// 'InnerSpace1::Test2' globally qualified
		PtrTest<::OuterSpace::InnerSpace1::Test2> test5;
		test5->|;	// NEARLY works ;)
		// (correctly suggests 'innerVar' 
		//  AND incorrectly 'someOtherVar' too)
	}

	////////////////////////////////////////////////
	// here same situation as first case 
	// (both namespaces at same level) but inside a common namespace
	namespace InnerSpace2
	{
		void testInner()
		{
			// 'InnerSpace1::Test2' locally qualified
			PtrTest<InnerSpace1::Test2> test4;
			test4->|;	// DOESN'T WORK 
			// (old behaviour -> no suggestion list box at all)
	
			// 'InnerSpace1::Test2' globally qualified
			PtrTest<::OuterSpace::InnerSpace1::Test2> test5;
			test5->|;	// NEARLY works ;)
			// (correctly suggests 'innerVar' 
			//  AND incorrectly 'someOtherVar' too)
		}
	}
}

////////////////////////////////////////////////
void testGlobal()
{
	// 'InnerSpace1::Test2' globally qualified
	PtrTest<::OuterSpace::InnerSpace1::Test2> test5;
	test5->|;	// NEARLY works ;)
	// (correctly suggests 'innerVar' 
	//  AND incorrectly 'someOtherVar' too)
}

int main()
{
}

Edited by - o2a on Jun 29 2006 2:30:50 PM
Go to Top of Page

o2a
Junior Member

24 Posts

Posted - Jun 29 2006 :  3:58:09 PM  Show Profile  Reply with Quote
Addendum to last case: When I tried this again just now (after restarting the IDE), the behaviour between test2 and test5 swapped at all places - i.e. test5 works now while for test2 VAX offers (incorrectly) someOtherVar and innerVar.

Ah, I see that VAX assumes the other Test2-class at the ambigious test1 places now. I had previously renamed the first Test2-class, did some testing and then restored the original situation - but this didn't restore the behaviour of VAX, even if I do a reparse (Alt-F5). Didn't try to rebuild symbols db yet.
Go to Top of Page

o2a
Junior Member

24 Posts

Posted - Jun 29 2006 :  4:22:49 PM  Show Profile  Reply with Quote
Addendum two (sorry ;-})
(don't know if it would be better to edit the old post?)

I should have tested the above case with normal pointers first. When I do this and add the following code to testInner() or testOuter(), I get the same behaviour as with test4, i.e. no autocomplete list box at all. So in this case it's not actually a problem with that overloaded operator->() "smart pointer"-like class but just a namespace problem.

Sorry for spamming so much cases, but I still have a problem in my actual project which I just can't nail down, that's why there are so many different versions here. I hope one of them finally leads to the real bug.

The situation in the actual project is similar, but there only the typedefed version has that problem (like test4_2 would work while test4_1 wouldn't).

Then again the differences between locally scoped (test4_1, test4_2) and globally scoped (test4_3, test4_4) indeed is reproducable in the context in the actual project.


		typedef InnerSpace1::Test2* InnerTest2Ptr;
		InnerTest2Ptr test4_1;
		test4_1->|;	// DOESN'T WORK 

		InnerSpace1::Test2* test4_2;
		test4_2->|;	// DOESN'T WORK 

		typedef ::OuterSpace::InnerSpace1::Test2* InnerTest2Ptr_2;
		::OuterSpace::InnerTest2Ptr_2 test4_3;
		test4_3->|;	// works

		::OuterSpace::InnerSpace1::Test2* test4_4;
		test4_4->|;	// works

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Jul 01 2006 :  2:09:44 PM  Show Profile  Reply with Quote
*um* first up, this is a very good bug report, just one that took rather a lot of working through

having worked through all of those tests, i am getting a different result, normally still wrong, for just about every single test. this is with VS2003, C++, VA 1526 and get content from default intellisense turned off.

for your second follow up post, for test4_3, you have a stray "::OuterSpace::", i had to remove that.

as a further difference, my results do not change when i re-start the IDE.

this is not the first time you have carefully reported a bug, but when i test your sample code i get a different result to you. something odd is going on here, but i don't know what it is.

case=1534

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

support
Whole Tomato Software

5566 Posts

Posted - Jul 10 2006 :  6:13:35 PM  Show Profile  Reply with Quote
The typedef problems will be fixed in 1531.
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