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
 coloring mixup on dynamic_cast
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sl@sh
Tomato Guru

Switzerland
204 Posts

Posted - Sep 19 2007 :  06:16:39 AM  Show Profile  Reply with Quote
Testcase:

1. enter the following code into your header file:
class CFoo {
public:
    virtual CFoo* Copy(const CFoo& other) const;
};
class CFooBar : public CFoo {
public:
    CFooBar();
    virtual CFooBar* Copy(const CFoo& other) const;
    CFooBar(const CFooBar& other);
};

2. enter the following code into your implementation file (don't forget to include the above header):
CFooBar* CFooBar::Copy(const CFoo& other) const
{
    CFooBar* newfoobar(NULL);
    newfoobar = new CFooBar(dynamic_cast<const CFooBar&>(other)); // comment this line out to see the change
    return newfoobar;
}

3. Check syntax coloring for the symbol, CFooBar. What I'm seeing is sth like this:
CFooBar* CFooBar::Copy(const CFoo& other) const
{
    CFooBar* newfoobar(NULL);
    newfoobar = new CFooBar(dynamic_cast<const CFooBar&>(other)); // comment this line out to see the change
    return newfoobar;
}

Apparently, VA still recognizes the class when used as a namespace, but not when used as a typename, or constructor name!

4. comment out the second line of the Copy function and check again - coloring is back to normal.

This code compiles well enough. Still, as long as the code contains a dynamic_cast, coloring is messed up for me!

Moreover: go to the second line in Copy, change the constructor call to
newfoobar = new CFooBar((dynamic_cast<const CFooBar&>(other)).|);
and see what kind of suggestions you get - I'm seeing CFoo::Copy(...) only, not the CFooBar functions.


P.S.: I noticed that removing the const qualifier within the dynamic_cast also fixes the coloring - apparently VAX has a problem with this qualifier inside a cast.



Version info:
VA_X.dll file version 10.3.1557.0 built 2007.05.29
Licensed to:
VA X: ...[snip]
VAOpsWin.dll version 1.3.2.2
VATE.dll version 1.0.5.6
DevEnv.exe version 7.10.3077.0
msenv.dll version 7.10.3077.0
Font: Courier New 13(Pixels)
Comctl32.dll version 5.82.2900.2982
Windows XP 5.1 Build 2600 Service Pack 2
2 processors

Platform: Win32
Stable Includes:
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\include;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\atlmfc\\include;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\PlatformSDK\\include\\prerelease;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\PlatformSDK\\include;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\SDK\\v1.1\\include;

Library Includes:
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\atlmfc\\src\\mfc;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\atlmfc\\src\\atl;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\crt\\src;

Other Includes:


Edited by - sl@sh on Sep 19 2007 08:12:21 AM

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Sep 19 2007 :  10:14:20 AM  Show Profile  Reply with Quote
I am seeing the same colouring problem:

case=2352

Producing a listbox on the dynamic cast return type, this is a "safety feature", to remind you never to do this without first checking that the returned pointer is valid

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

sl@sh
Tomato Guru

Switzerland
204 Posts

Posted - Sep 20 2007 :  04:33:53 AM  Show Profile  Reply with Quote
quote:
Originally posted by feline
Producing a listbox on the dynamic cast return type, this is a "safety feature", to remind you never to do this without first checking that the returned pointer is valid


Actually, when you dynamic_cast sth to a class without qualifier, the listbox works just fine.

I also found a workaround for this problem, by first defining a typedef:
typedef const CFooBar& CRCFooBar;
...
dynamic_cast<CRCFooBar>(other)
...

This resolves both the coloring and the listbox problem, without changing the semantics.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Sep 20 2007 :  10:08:35 AM  Show Profile  Reply with Quote
A very interesting solution, thank you for posting that. I have made a note of this on the case for future reference

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 14 2008 :  2:52:17 PM  Show Profile  Reply with Quote
case=2352 is fixed in build 1645

Whole Tomato Software, Inc.
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