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

Gabriel Dos Reis gdr@integrable-solutions.net
Mon Dec 2 14:56:00 GMT 2002


The following reply was made to PR c++/8772; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: bangerth@dealii.org
Cc: gcc-bugs@gcc.gnu.org, zack@codesourcery.com, pcarlini@unitus.it,
   sneechy@hotmail.com, gcc-gnats@gcc.gnu.org
Subject: Re: c++/8772: Segmentation fault on 3 lines of template code
Date: 02 Dec 2002 23:49:28 +0100

 bangerth@dealii.org writes:
 
 | Synopsis: Segmentation fault on 3 lines of template code
 | 
 | State-Changed-From-To: open->analyzed
 | State-Changed-By: bangerth
 | State-Changed-When: Mon Dec  2 12:45:29 2002
 | State-Changed-Why:
 |     Others have confirmed this already.
 |     
 |     However, just for the record: I fail to see how this can be
 |     made legal: when you write A<n>::B to denote the template
 |     type, B is a template dependent type, and one would think
 |     one has to write a "typename" somewhere. But then we have
 |       typename A<n>::B
 |     which is not the name of a type, but of a template. I don't
 |     know what the standard says here, but I don't see a way to
 |     make it legal in any case.
 
 This case seems to be forgotten by the standard.  I think the
 following should make GCC happy.
 
   template<int n>
      struct D  {
        enum { 
          v = C<A<n>::template B>::v
        };
      };
 
 Note the "template" keyword in front of B.
 
 The closest you can find in the standard is 14.2/
 
     4
       When the name of a member template specialization appears after . or
       -> in a postfix-expression, or after nested-name-specifier in a
       qualified-id, and the postfix-expression or qualified-id explicitly
       depends on a template-parameter (14.6.2), the member template name
       must be prefixed by the keyword template. Otherwise the name is
       assumed to name a non-template. [ example not reproduced ]
 
     5
       If a name prefixed by the keyword template is not the name of a
       member template, the program is ill-formed.
 
 -- Gaby



More information about the Gcc-prs mailing list