This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

typename bug ?



I have some problems with typename, and I m not sure if the
problem is with egcs or with my understanding of the standard:

the following code :
[-------------
//struct some_struct; typedef some_struct* ptr; (3)

template <class T> struct A {typedef T* ptr;};

template <class T> struct B : public A<T> {
  public:
  void f(ptr& p); // (1)
};

template <class T> void B<T>::f(ptr& p) { p = 0;}

//template<> struct A<int> { typedef void* some_type;}; (2)

int main() {
  B<int> b;
  int i; int* ip = &i;
  b.f(ip);
  return 42;
}
----------]  
compile with no error with egcs, but
since the names declared in A<T> are not suppose to be 
considered until instanciation os B<int>, it seems that a typename
is missing (and if you uncomment line (2), you can see
there is actualy a problem). But I don't find that the standard 
is really clear on that point so I'm not sure (HP aCC 1.15 flags 
(1) as an error, but Dec cxx 6.1 does not)

Moreover, if you uncoment (3), the program compiles without
problem, which contradict 14.6.2(3)

Alain

PS: configuration
Reading specs from
/nfs/server4/miniussi/egcs/solar/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.58/specs
gcc version egcs-2.91.58 19981101 (egcs-1.1.1 pre-release)

/nfs/server4/miniussi/egcs/solar/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.58/cpp
-lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91
-Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__
-D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4)
-D__EXCEPTIONS -Wall -pedantic -D__GCC_NEW_VARARGS__ -Acpu(sparc)
-Amachine(sparc) typename.cpp /var/tmp/ccpGWWnA.ii
GNU CPP version egcs-2.91.58 19981101 (egcs-1.1.1 pre-release) (sparc)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]