Bug Vanquisher

18 April 2007

Start getting dirty with Visual Studio Orcas

Filed under: Bugz, C++, Orcas — Tanveer Badar @ 11:42 AM

I got my hands on VS Orcas March CTP yesterday and tried compiling CPlusPlusCodeProvider on which I have been working for five years. The code has compiled and worked flawlessly on all previous versions of VC++ [VC++ .Net to VC++ 2005], but now the new compiler reports an error on assignments lines involving auto_ptr objects.

Whenever I have tried to do <object> = new <type>( *other.<member> );, this new compiler whines. Compiler gives error about ambiguous assignment operators. Says it cannot choose between std::auto_ptr< Inner >::operator = ( const std::auto_ptr< Inner >& ) and std::auto_ptr_ref< Inner >::operator = ( const std::auto_ptr_ref< Inner >& ).

When I looked at the source for auto_ptr none of the classes had assignment operators defined, so the compiler is generating the default implementations. However, they both have a public constructor declared like this auto_ptr( T* ptr ) and auto_ptr_ref( T* ptr ).

I don’t remember if these converting constructors should cause any ambiguity. Converting constructor for auto_ptr is more qualified than auto_ptr_ref. It should be the one that handles this conversion, instead of creating any ambiguity.

As I remember the standard, you cannot create an instance of auto_ptr_ref directly, therefore, this constructor should not be declared public but protected. If declared public, it should have been declared explicit in the first place. Moreover, in the library shipping with VC++ 2005, auto_ptr does not derive from auto_ptr_ref. It has just a converting constructor.

I know VC++ team does not write the libraries themselves, instead it is Dinkumware that should be blamed, if it is really incorrect code.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: