When I declare a class A, gcc injects the class name A in this class a little
too strongly.

C++0X explicitly lists this example as invalid (and it is also invalid in
C++03, just not explicitly given as an example):
struct A {};
void f(){ A::A a; }

This is only a failure to emit an error/warning, but I found several libraries
developed with g++ that use the following non-portable construct:

template <class T> struct A {
  A(double d){}
};
template <class T> struct B : A<T> {
  B(double d):A<T>::A(d){}
};

A diagnostic would be really helpful. Sun Studio for instance rejects the code
as soon as you try to instantiate it.

The most relevant part of the standard is 3.4.3 (and 3.4.3.1). These sections
were expanded quite a bit from C++03 to C++0X, and have become quite confusing,
but this last example was invalid in C++03 and I hope it still is in C++0X.


-- 
           Summary: injected class name is too available
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: marc dot glisse at normalesup dot org
  GCC host triplet: i486-linux-gnu


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

Reply via email to