Search

Incorrect deduction when taking the address of an instantiated member function template using a template type by eldiener

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 651762
Opened: 3/16/2011 7:24:26 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
When taking the address of an instantiated member function template where the enclosing type is being passed as a template type parameter, VC++ 10 does consider the erxpression valid.
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010 SP1

What category (if any) best represents this feedback?

Reliability

Steps to reproduce

Compiling this code:

struct AType
{
template<class X,class Y,class Z,short AA> double SomeFuncTemplate(X,Y *,Z &) { double ret(AA); return ret; }
};

template
<
class T
>
struct TTest
{
typedef char Bad;
struct Good { char x[2]; };
template<T> struct helper;
static Good check(helper<&AType::template SomeFuncTemplate<int,long,double,50> > *);
static Bad check(...);
static const bool value=sizeof(check(0))==sizeof(Good);
};

template
<
class T,
class C
>
struct TTest2
{
typedef char Bad;
struct Good { char x[2]; };
template<T> struct helper;
template<class U> static Good check(helper<&U::template SomeFuncTemplate<int,long,double,50> > *);
template<class U> static Bad check(...);
static const bool value=sizeof(check<C>(0))==sizeof(Good);
};

int main()
{

static_assert(TTest
                 <
                 double (AType::*)(int,long *,double &)
                 >::value,
                "failure in TTest"
             );
            
static_assert(TTest1
                 <
                 double (AType::*)(int,long *,double &),
                 AType
                 >::value,
                "failure in TTest1"
             );
            
static_assert(TTest2
                 <
                 double (AType::*)(int,long *,double &),
                 AType
                 >::value,
                "failure in TTest2"
             );
            
return 0;

}

a static_assert will trigger as "failure in TTest2". It should of course not happen.

Product Language

English

Operating System

Windows Vista

Operating System Language

English

Actual results

static_assert of "failure in TTest2".

Expected results

No static_assert should trigger.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 9/22/2011 at 10:40 PM
Hi: this issue has been fixed. The fix should show up in a future release of Visual C++.

Thank you for reporting the issue.

Jonathan Caves
Visual C++ Compiler Team
Posted by Microsoft on 6/23/2011 at 4:00 PM
I have reactivated this bug in our internal database (DevDiv#161662). It still appears as Resolved on Connect because I don't know how to change that.

Stephan T. Lavavej
Visual C++ Libraries Developer
stl@microsoft.com
Posted by eldiener on 6/2/2011 at 12:27 PM
Once again, you have specified that this is "Resolved as By Design" on completely false pretences. Your analyses is obviously flawed and the only justification for such a flawed analyses is that you want to claim that an obvious bug in your C++ compiler is "by design". Please take a look at this again rather than falsely closing a bug report because of the horrible incompetence of one Tanveer Gani of your Visual C++ team.
Posted by eldiener on 5/26/2011 at 8:23 AM
It does not "reduce" to the example below. In my longer example in TTest2 the 'check' function gets passed its U parameter so it does not have to deduce it.
Posted by Microsoft on 5/25/2011 at 6:12 PM
Thank you for contacting us. Your repro reduces to this:

struct AType
{
     template<class X> double SomeFuncTemplate();
};
template <class T,class C> struct TTest2
{
     template<T> struct helper;
     template<class U> static void check(helper<&U::template SomeFuncTemplate<int> > *);
};
int main()
{
     TTest2<double (AType::*)(), AType>::check(0);
}

There is no way for the compiler to deduce "U" since a non-deduced context is involved. Please see 14.8.2.4, para 4 in the ISO Standard.

Regards,

Tanveer Gani
Visual C++ Team.
Posted by Microsoft on 3/16/2011 at 7:56 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by Microsoft on 3/16/2011 at 8:13 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)
Sign in to post a workaround.