View Single Post
  #1 (permalink)  
Old 03-25-2012, 11:36 PM
Nikolay Ivchenkov
Guest
 
Posts: n/a
Default Accessibility of inherited injected-class-names

Consider the following example:

template <class T>
struct A {};

struct B : private A<void> {};

struct C : B
{
A<void> a; // A is the injected-class-name of A<void>
};

int main() {}

As far as I understand, in the declaration of C::a identifier A
denotes the injected-class-name of A<void> (i.e. ::A<void>::A) which
is inaccessible within C (thus, the program is ill-formed and a
diagnostic message is required). Is my understanding correct?

The behavior of compilers differs:

1) GNU C++ 4.8.0, Clang 3.0, and VC++ 10.0 do not issue any error or
warning.

2) Intel C++ 12.1 issues the following diagnostic message:

(8): error #308: type "A<T>::A [with T=void]" (declared at line 2)
is inaccessible
A<void> a;
^

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Reply With Quote