BUG (VC7.1 and Whidbey): compiler allows access to private definitions in some cases

  • Thread starter Thread starter Maxim Yegorushkin
  • Start date Start date
M

Maxim Yegorushkin

Code to reproduce the bug (Comeau refuses to compile the code, but VC has
no complain about it):

template<class T, class S>
class M
{
private:
struct m_tag;
};

template<class T>
struct is_m
{
template<class U>
static char is_m_helper(U*, typename U::m_tag*);

static double is_m_helper(...);

static T* t;
enum { value = sizeof(is_m_helper(t, 0)) == sizeof(char) };
};

struct A : M<void, void> {};
struct B;
class C : private M<void, void> {};

typedef char a[is_m<A>::value]; // must not compile
typedef char b[!is_m<B>::value];
typedef char c[is_m<C>::value]; // must not compile

m_tag is a private nested struct declaration. How does it come out that
is_m_helper() has access to it (after SFINAE has been applied)?
 
Back
Top