[cfe-dev] Weird diagnostic about non-type template argument
Enea Zaffanella
zaffanella at cs.unipr.it
Mon Aug 16 02:24:08 PDT 2010
Chandler Carruth wrote:
> On Mon, Aug 16, 2010 at 12:31 AM, Abramo Bagnara
> <abramo.bagnara at gmail.com <mailto:abramo.bagnara at gmail.com>> wrote:
[... snip ...]
> 3) that apart the diagnostic message is misleading: non-type template
> argument might (and sometimes should, see the following line in source)
> be surrounded by parentheses
>
>
> The second line is a completely different non-type template argument: an
> integral constant-expression. There are no parentheses around the
> template argument, there are parentheses as part of the
> constant-expression, which allows parentheses among many other
> constructs. It is certainly unfortunate that there is no way to write a
> '>' in an ICE without parentheses, but I don't think that artifact
> necessarily warrants allowing parentheses for all template arguments, or
> even for all non-type template arguments...
I think that, in point 3, Abramo was just referring to the wording of
the diagnostic, which maybe could be improved.
I don't think that usual C++ programmers can easily tell the difference
(if any) from a non-type template argument and the constant expression
that denotes a non-type template argument. So, it might be appropriate
to change the message wording to something like:
non-type template argument having pointer type cannot be surrounded by
paretheses
or
pointer-type expression used as non-type template argument cannot be ...
or something similar.
Cheers,
Enea.
More information about the cfe-dev
mailing list