Home Dashboard Directory Help
Search

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


Status: 

Closed
 as Won't Fix Help for as Won't Fix


2
0
Sign in
to vote
Type: Bug
ID: 464600
Opened: 6/5/2009 10:49:03 AM
Access Restriction: Public
0
Workaround(s)
view
1
User(s) can reproduce this bug

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;
}
Details
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:".
Sign in to post a workaround.