Search

Function pointer to templated function becomes that of non-templated function of the same name by Lasse Reinhold

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 748530
Opened: 6/12/2012 3:38:58 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Function pointer to templated function of a class is set to non-templated version if declaration and association of the pointer are on two different source code lines.

Happens only if templated function is a class member.

NOTE: I *think* I have also seen the same behaviour on *calls* to the templated version too...
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

Visual Studio 2012 RC

What category (if any) best represents this feedback?

 

Steps to reproduce

class.cpp
--------------------------
#include <stdio.h>
#include "class.h"

template <int V> int Heyo::Get(void) {
    return 111;
}

int Heyo::Get(void) {
    return 222;
}

int Heyo::GetStuff(void) {
typedef int(Heyo::*Getter)(void);

    Getter getter1;
    getter1 = &Heyo::Get<8>;
    Getter getter2 = &Heyo::Get<8>;
    Getter getter3 = &Heyo::Get;

    printf("getter1 = %x\ngetter2 = %x\ngetter3 = %x\n\n", getter1, getter2, getter3);

    return 0;
}


class.hpp
--------------------------------------
class Heyo
{

template <int V> int Get(void);
int Get(void);

public:
typedef int(Heyo::*Getter)(void);

public:
    int GetStuff(void);

private:
    Getter getter1;
    Getter getter2;
};


template.cpp
------------------------------
#include <stdio.h>
#include "class.h"

void main(void)
{
    Heyo h;
    h.GetStuff();
}

Product Language

English

Operating System

Windows 7

Operating System Language

English (Australian)

Actual results

getter1 != getter2

Expected results

getter1 == getter2

Locale

 
File Attachments
File Name Submitted By Submitted On File Size  
template.zip 6/12/2012 55 KB
Sign in to post a comment.
Posted by Microsoft on 9/6/2012 at 4:04 PM
Hi Lasse:
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next major release of Visual C++.
    If you see similar issue when call function template with explicit template argument, could you give us a repro?

Xiang Fan
Visual C++ Team
Posted by Microsoft on 6/13/2012 at 12:58 AM
Thank you for submitting feedback on Visual Studio 11 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 6/12/2012 at 3:50 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.