c++/6601: [parser] Parse error when using :: qualified name in template
Wolfgang Bangerth
bangerth@math.ethz.ch
Thu May 16 02:56:00 GMT 2002
> Thanks, who would have thought about di-graphs ;) ? I hesitated a while
> to submit a bug report, because I thought somebody else surely must have
> caught this before. I finally did it since the Kai compiler compiled the
> code without complaints, but it turns out that it has digraphs disabled
> in the default mode and you have to give some --strict option to enable
> them.
>
> Maybe this can go into that 'bugs which aren't really bugs' web page you
> got ? It might give people a clue when they run into similar problems.
I append a patch to bugs.html below which lists this as a non-bug. It
might be worthwhile for both 3.1 and 3.2.
Regards
Wolfgang
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@math.ethz.ch
www: http://www.math.ethz.ch/~bangerth
Index: bugs.html
===================================================================
RCS file: /cvsroot/gcc/wwwdocs/htdocs/bugs.html,v
retrieving revision 1.56
diff -c -r1.56 bugs.html
*** bugs.html 14 May 2002 17:23:17 -0000 1.56
--- bugs.html 16 May 2002 07:56:59 -0000
***************
*** 614,619 ****
--- 614,643 ----
<a href="http://www.validlab.com/goldberg/paper.ps">this paper</a>
for more information.</p></dd>
+ <dt><em>Templates, scoping, and digraphs.</em></dt>
+
+ <dd><p>If you have a class in global namespace, say named
+ <code>X</code>, and want to give it as a template argument to some
+ other class, say <code>std::vector</code>, then this here fails with a
+ parser error: <code>std::vector<::X></code>.
+ </p>
+
+ <p>
+ The reason is that the standard mandates that the sequence
+ <code><:</code> is treated as if it were the token
+ <code>[</code>, and the parser then reports a parse error before the
+ character <code>:</code> (by which it means the second
+ colon). There are several such combinations of characters, and
+ they are called <em>di-graphs</em>.
+ </p>
+
+ <p>
+ The simplest way to avoid this is to write <code>std::vector<
+ ::X></code>, i.e. place a space between the opening angle bracket
+ and the scope operator.
+ </p></dd>
+
+
</dl>
<h3><a name="missing">Missing features</a></h3>
More information about the Gcc-patches
mailing list