Specialized Template definition order -> no undeclared identifier error  
Author Message
Daniel Segerdahl





PostPosted: Visual C++ Language, Specialized Template definition order -> no undeclared identifier error Top

Hi!
Have a look at this code:

// test.h START
template<class A> void funcT(A a);
void funcF(float a);

template<class A> void funcT(A a) {
}
void funcF(float a) {
funcT(a);
}
// test.h END

// test.cpp START
#include "test.h"
int test() {
for(int i=0;i<3;i++)
i++;
return i;
}
// test.cpp END

When compiling it (VS2005), it gives the error "1>.\test.cpp(6) : error C2065: 'i' : undeclared identifier". This was my intention. But if I switch the funcF and funcT definitions in "test.h" like this:

// test.h START
template<class A> void funcT(A a);
void funcF(float a);

void funcF(float a) {
funcT(a);
}
template<class A> void funcT(A a) {
}
// test.h END

When compiling, the C2065 error is gone!
How could this be

Best regards Daniel Segerdahl.


Visual C++3  
 
 
einaros





PostPosted: Visual C++ Language, Specialized Template definition order -> no undeclared identifier error Top

Nifty bug. That's definitely not what should happen

Report the issue at http://connect.microsoft.com/VisualStudio, and paste the url here afterwards.



 
 
einaros





PostPosted: Visual C++ Language, Specialized Template definition order -> no undeclared identifier error Top

Interestingly, VC6-VC8 all seem to have the same behavior, Comeau reports an error no matter how you arrange it and EDG successfully compiles either way ..

 
 
Daniel Segerdahl





PostPosted: Visual C++ Language, Specialized Template definition order -> no undeclared identifier error Top

Hi!
I've looked everywhere now and I can't report the bug. When I click "Submit a Bug or Suggestion" I come to a page which says: "You need permission to submit feedback in this area. To apply for permission, browse through your choices on the Available Connections page.". I have browsed "everywhere" and can't find out how to "apply for permission" for "Visual Studio and .NET Framework".

/Daniel

 
 
Daniel Segerdahl





PostPosted: Visual C++ Language, Specialized Template definition order -> no undeclared identifier error Top

OK, I found it.
/Daniel

 
 
Daniel Segerdahl





PostPosted: Visual C++ Language, Specialized Template definition order -> no undeclared identifier error Top

I have submitted the bug found here:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx FeedbackID=253643

/Daniel