Bug 29328 - calling convention attributes not encoded in member function pointer
Summary: calling convention attributes not encoded in member function pointer
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid, wrong-code
: 65789 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-10-03 09:43 UTC by Tobias Schwinger
Modified: 2021-07-23 11:52 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-10-05 04:56:52


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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. ***