Search

typeid result of pointer to static member function or reference to static member function by Butterflow

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

0
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 264937
Opened: 3/23/2007 7:44:05 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
In VC71SP1, VC8 and VC8SP1, when pointer to static member function in form of &foobar::bar is given as the operand of typeid, it returns type_info instance for the reference to static member function. In other words, the result of typeid( &foobar::bar ) and the result of typeid( foobar::bar ) are the same when foobar::bar is a static member function.

But for the free function, typeid returns two different type_info object as it should be. So the result of typeid( &hello ) and the result of typeid( hello ) are not the same when hello is a free function.

In gcc, typeid returns different type_info instance for both cases.
Details (expand)
Product Language
English

Version

Visual Studio 2005 (All Products and Editions) Service Pack 1
Operating System
Windows XP Professional
Operating System Language
English
Steps to Reproduce
#include "stdafx.h"
#include <cassert>
#include <iostream>

int hello(int) { return 0; }

struct foobar
{
int foo(int) { return 0; }
static int bar(int) { return 0; }
};

int _tmain(int argc, _TCHAR* argv[])
{
std::cout << typeid( &hello ).name() << std::endl;
std::cout << typeid( hello ).name() << std::endl;

assert( typeid( &hello ) != typeid( hello ) );

std::cout << typeid( &foobar::foo ).name() << std::endl;

std::cout << typeid( &foobar::bar ).name() << std::endl;
std::cout << typeid( foobar::bar ).name() << std::endl;

assert( typeid( &foobar::bar ) != typeid( foobar::bar ) ); // (A)

return 0;
}
Actual Results
1. typeid( &foobar::bar ).name() is "int __cdecl(int)".
2. assertion failed at the line (A)
Expected Results
1. typeid( &foobar::bar ).name() should be "int (__cdecl*)(int)".
2. no assertion fail at the line (A)
TAP Code (if applicable)
 
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey. [Details]

 

File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 3/25/2007 at 6:40 PM
Thank you for your feedback. We are currently investigating. If this issue is urgent, please call support directly (see http://support.microsoft.com). Thank you, Visual Studio Product Team.
Posted by Microsoft on 3/25/2007 at 8:53 PM
Thanks for your feedback. We have reproduced this bug on <VSTS SP1>, and we are sending this bug to the appropriate group within the Visual Studio Product Team for triage and resolution. Thank you, Visual Studio Product Team.
Posted by Microsoft on 3/27/2007 at 3:32 PM
Thank you for sending us feedback. The Visual C++ team has evaluated the bug and determined it does not meet the guidelines necessary to warrant a fix. To understand these guidelines please refer to http://blogs.msdn.com/vcblog/articles/621116.aspx.

Unfortunately, the Visual C++ development team cannot provide workarounds for issues submitted via the Microsoft Connect interface. The MSDN forums are better suited for finding the correct answer. Visit the MSDN forums at http://forums.microsoft.com/msdn/default.aspx.

Comments from the triage team: This doesn't meet the Orcas triage guidelines for the compiler.

Thanks once again for taking the time to send us feedback,
The Visual C++ Triage Team