[Bug c++/20439] New: Dropped attributes on class members

tschwinger at neoscientists dot org gcc-bugzilla@gcc.gnu.org
Sat Mar 12 14:23:00 GMT 2005


//==============================================================================
// Dropped attributes on class member
//==============================================================================
// $ g++ -ansi -pedantic -Wall -c <file>
// Output: 
//   ... 'ASSERTION_FAILED_IN_LINE_42' ...
// Known to fail with:
//   3.4.3 (linux)
//   3.4.2 (linux)
//   3.4.2 (mingw)
//   3.3.4 (linux)
//   3.2.3 (mingw)
// Known to work with:
//   4.0.0-beta (linux)
//==============================================================================

//------------------------------------------------------------------------------
// 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_SAME_TYPE(x,y) ASSERT_SAME_TYPE_IMPL_I(__LINE__,x,y)
#define ASSERT_SAME_TYPE_IMPL_I(i,x,y) ASSERT_SAME_TYPE_IMPL_II(i,x,y)
#define ASSERT_SAME_TYPE_IMPL_II(i,x,y) \
  bool ASSERTION_FAILED_IN_LINE_ ## i  [ ::same<x,y>::n ]

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

#define CC __attribute__((__stdcall__))

typedef void CC type();
ASSERT_SAME_TYPE(type,void CC ()); // ok

struct X
{
  typedef void CC type();
};
ASSERT_SAME_TYPE(X::type,void CC ()); // <- here

//------------------------------------------------------------------------------

-- 
           Summary: Dropped attributes on class members
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tschwinger at neoscientists dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20439



More information about the Gcc-bugs mailing list