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

Gabriel Dos Reis gdr@integrable-solutions.net
Sat Jan 18 11:02:00 GMT 2003


Wolfgang Bangerth <bangerth@ticam.utexas.edu> writes:

| > 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>

Actually I suggeted:

  C<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"?

Yes, that is what I talking about.  Incidently, as I said, Iraised the
issue ad John Spicer (EDG) tolad me that he already came across the
same issue, made a (revised) suggestion that matches mine, see

   http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/papers/2000/n1231.html

| 
| If yes, then I would say gcc presently does its best and we should close 
| the report.

Well, the diagnostic is still incorrect; I believe we should rephrase
teh synopsis to indicate that

| 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.

This is already reported to committee and there seems to be agreement
that the code should be made work with 'template' prefix.

-- Gaby



More information about the Gcc-bugs mailing list