Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2005

Tip: Looking for answers? Try searching our database.

Dependent names lookup in VC2005 B2

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
adebaene@club-internet.fr - 16 Jun 2005 09:09 GMT
Hello all,

I just checked that the following did compile with VC2005 b2, and I
think it shouldn't:

template <typename T> struct A
{
 typedef int Foo;
};

template <typename T> class B : public A<T>
{
  Foo i;  //line 1
};

int main()
{
  B<float> b;
}

I believe that Foo is a dependent-name in B context, and therefore line
1 should be "typename A<T>::Foo i;".

Comeau online and gcc seems to agree with my reasoning, but I am quite
unable to fully understand norm 14.6.2. Could anyone shed some light on
this? Is this code legal or not?

Arnaud
MVP - VC
Doug Harrison [MVP] - 16 Jun 2005 16:15 GMT
> Hello all,
>
[quoted text clipped - 22 lines]
> unable to fully understand norm 14.6.2. Could anyone shed some light on
> this? Is this code legal or not?

No, the code above isn't legal. If you remove A<T> as a base class and
refer to Foo with A<T>::Foo, I expect you'll get an error. If instead you
add "int Foo;" as a global in front of B's defintion, I expect you won't
get an error. The problem is that VC still doesn't correctly implement the
"two-phase" lookup rule and is still quite lax about looking into template
bases.

Signature

Doug Harrison
Microsoft MVP - Visual C++

Hendrik Schober - 16 Jun 2005 16:24 GMT
> > Hello all,
> >
[quoted text clipped - 24 lines]
>
> No, the code above isn't legal. [...]

 I think it is indeed illegal. Comeau agrees.
 <lazy_mode>I'm sure CW agrees, too. At least
 it keeps finding such errors that VC let's
 me get away with.</lazy_mode>

 Schobi

Signature

SpamTrap@gmx.de is never read
I'm Schobi at suespammers dot org

"Coming back to where you started is not the same as never leaving"
Terry Pratchett


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.