c++/8772: Segmentation fault on 3 lines of template code

Wolfgang Bangerth bangerth@ticam.utexas.edu
Fri Jan 17 18:16:00 GMT 2003


> What are we going to do with the PR w.r.t. the how-to-make-to-code-legal
> issue? Leave it open, close it, suspend it, open a new PR?

Good question. Just to recall this briefly: this code
---------------
template <int> struct A {
    template <int> struct B { enum { v = 1 }; };
};

template <template <int> class F> struct C {
    enum { v = F<1>::v || 2 };
};

template <int n> struct D {
    enum { v = C<A<n>::B>::v };
};
-----------------------
generated an ICE (now errors), and the question was: is in the last line
  C<A<n>::B> 
something meaningful? Wouldn't we have to write
  C<typename A<n>::B>
? This doesn't compile either presently. 

Gaby's suggestion was that this needs to be further disambiguated as
  C<typename A<n>::template B>
which would not be covered by the standard (the oversight Gaby spoke of), 
but be reasonable. However, this still doesn't compile presently:
  g/a> /home/bangerth/bin/gcc-3.4-pre/bin/gcc -c x.cc
  x.cc:10: error: template argument 1 is invalid

What does compile is (also with icc7, by the way)
  C<A<n>::template B>

Gaby, is the latter the syntax you had in mind to be legal, i.e. put 
differently: no need for "typename"?


If yes, then I would say gcc presently does its best and we should close 
the report. If the inquire Gaby did with the ISO committee finds some 
other solution, then this will be put into a DR anyway, and there is no 
need to keep the report open presently anyway.

Regards
  Wolfgang

-------------------------------------------------------------------------
Wolfgang Bangerth             email:            bangerth@ticam.utexas.edu
                              www: http://www.ticam.utexas.edu/~bangerth/




More information about the Gcc-bugs mailing list