C++ compiler generates error C2783 on valid code - by RicarDog

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


2
0
Sign in
to vote
ID 464600 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 6/5/2009 10:49:03 AM
Access Restriction Public

Description

The following valid ISO C++ code generates error C2783. The same error occurs in VS2008. It compiles normally in Intel C++ Compiler 11.


#include <iostream>

template<typename T>
class IsClassT {
  public:
    typedef char One;
    typedef struct { char a[2]; } Two;
    template<typename C> static One test(int C::*);
    template<typename C> static Two test(...);
  public:
    enum { Yes = sizeof(IsClassT<T>::test<T>(0)) == 1 };
    enum { No = !Yes };
};

int main ()
{
	if (IsClassT<int>::Yes)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;
	
	return 0;
}
Sign in to post a comment.
Posted by Microsoft on 6/9/2009 at 10:10 AM
Hi: I can confirm that this is a bug with Visual C++. Unfortunately it does not meet the triage bar for the current release of Visual C++ - but we will keep the issue in our database and we will look at it again during the development phase of a future release of Visual C++.

A possible workaround is to use:

sizeof(test<T>(0))

Jonathan Caves
Visual C++ Compiler Team
Posted by Microsoft on 6/8/2009 at 4:27 AM
Thank you for your feedback, We are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by RicarDog on 6/5/2009 at 10:54 AM
Typo (but does not affect the problem): the first "public:" should be "private:".