Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 coloring mixup on dynamic_cast

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
sl@sh Posted - Sep 19 2007 : 06:16:39 AM
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:

4   L A T E S T    R E P L I E S    (Newest First)
support Posted - Jul 14 2008 : 2:52:17 PM
case=2352 is fixed in build 1645
feline Posted - Sep 20 2007 : 10:08:35 AM
A very interesting solution, thank you for posting that. I have made a note of this on the case for future reference
sl@sh Posted - Sep 20 2007 : 04:33:53 AM
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.
feline Posted - Sep 19 2007 : 10:14:20 AM
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

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000