seemingly valid dependant types in nested template not accepted - by evan.teran

Status : 

  Postponed<br /><br />
		Due to current priorities, the product team decided to postpone the resolution of this item.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 354162 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 6/29/2008 1:30:08 AM
Access Restriction Public


I have encountered a block of code which vc++ rejects but some others compilers accept. When asking other people about the code, none of us can see any reason why it should be rejected. The code in question is:


template<int N>
class A {
       typedef int T;

       template<T F1>
       void f();


template<int N>
template<typename A<N>::T F1>
void A<N>::f() {


int main() {
       A<0> x;


This produces the following error (obviously replacing "typename A<N>::T" with "int" works, so it seems to be an issue with looking up typedefs in a template type):

1>------ Build started: Project: Test, Configuration: Debug Win32 ------
1>c:\users\USER\desktop\test\main.cpp(15) : error C2244: 'A<N>::f' : unable to match function definition to an existing declaration
1>        definition
1>        'void A<N>::f(void)'
1>        existing declarations
1>        'void A<N>::f(void)'
1>Build log was saved at "file://c:\Users\USER\Desktop\Test\Debug\BuildLog.htm"
1>Test - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Sign in to post a comment.
Posted by Microsoft on 7/28/2008 at 12:38 PM
Thank you for your feedback!

This is indeed a bug with the compiler. It appears that the compiler is unable to discover the equivalence of the typedef inside and outside of the declaration of A. As you stated, you can directly mention int instead of the typedef in order to workaround this issue. Since this is a conformance issue and there a reasonable workaround this bug does not meet the bar for Dev10. We will, however, re-consider this bug when our compiler front-end overhaul comes online in a future version of Visual Studio.

Peter-Michael Osera
Visual C++ Compiler Team
Posted by Microsoft on 6/30/2008 at 1:47 AM
Thanks for your feedback. We are escalating this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team