This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

Re: c++/3831: problem with forward declaration of function taking a reference to a generic member


3.4 behaves totally differently on the examples.

I believe the stated problem is fixed.  However, I need to verify that the 
two changes I made to the examples to get them to work are, in fact, fixes 
needed to make the code legal.  (If not, I have revealed other bugs...)

If the definition of struct A is moved above the forward declaration of g, 
and the use of 'typename' inside the formal arguments is removed in all 
cases, all is well.
--
template <typename u> struct A;

template <typename u> struct A {
    template <typename v> struct B { };
 };
 
template <typename u, typename v> void g(A<u>::B<v>&);

template <typename u, typename v> void g(A<u>::B<v>&);
  
int main() {
    A<int>::B<float> b;
    g<int, float>(b);
 }
--

I believe that the definition of struct A needs to be above the declaration 
of g because otherwise B isn't declared at the time of declaration of g.  I 
can't figure out a way to declare B before the definition of A.  If there is 
one in the C++ standard, I'll be happy to use it and see if that works.

I don't know why the 'typename' has to be removed from inside the arguments.
But it it isn't removed, g++ 3.4 does the same thing as it does if B isn't 
declared before g: it decides that g is not a function (calls it a "variable 
or field").

--Nathanael


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