Bug 29328

Summary: calling convention attributes not encoded in member function pointer
Product: gcc Reporter: Tobias Schwinger <tschwinger>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: gcc-bugs, jason, puetzk, s__nakayama, webrown.cpp
Priority: P3 Keywords: accepts-invalid, wrong-code
Version: 4.1.1   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2006-10-05 04:56:52

Description Tobias Schwinger 2006-10-03 09:43:32 UTC
// Tested with 4.1.1 and 4.2.0-alpha20060520

//------------------------------------------------------------------------------
// Simple compile time assertion facility to check the identity of two types
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

template<typename X, typename Y> struct same      { enum { n = -1 }; };
template<typename X>             struct same<X,X> { enum { n = 1 }; };
#define ASSERT_DIFFERENT_TYPE(x,y) ASSERT_DIFFERENT_TYPE_IMPL_I(__LINE__,x,y)
#define ASSERT_DIFFERENT_TYPE_IMPL_I(i,x,y) ASSERT_DIFFERENT_TYPE_IMPL_II(i,x,y)
#define ASSERT_DIFFERENT_TYPE_IMPL_II(i,x,y) \
    bool ASSERTION_FAILED_IN_LINE_ ## i  [ - ::same<x,y>::n ]


//------------------------------------------------------------------------------
// The problem
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

ASSERT_DIFFERENT_TYPE(void(*)(),void(__attribute((stdcall)) *)()); // OK

class X;
ASSERT_DIFFERENT_TYPE(void(X::*)(),void(__attribute((stdcall)) X::*)()); // FAIL
Comment 1 Andrew Pinski 2006-10-05 04:56:51 UTC
Here is a shorter testcase which shows the problem:
class X{};
void (X:: *b)();
void (__attribute((stdcall))X:: *c)() = b;


This also can create wrong code too.
Comment 2 Andrew Pinski 2021-07-23 01:35:50 UTC
*** Bug 65789 has been marked as a duplicate of this bug. ***