[cfe-dev] Weird diagnostic about non-type template argument

Abramo Bagnara abramo.bagnara at gmail.com
Mon Aug 16 00:31:23 PDT 2010


The following typescript show the issue:

$ cat t.cc

template <int *ptr>
struct S1 { };

template <bool b>
struct S2 { };

int v1;

S1<(&v1)> x;
S2<(2>2)> y;
$ clang -c t.cc
t.cc:10:4: error: non-type template argument cannot be surrounded by
parentheses
S1<(&v1)> x;
   ^~~~~
1 error generated.

My notes:

1) in my opinion the diagnostic is due to a needless too strong
interpretation of the standard:

- comeau and intel does not mark this as an error

- gcc seems to mark this as an error due to some bug (the diagnostic  is
very weird)

2) also if there is disagreement about 1 I don't see the reason to
generate an error instead of a warning

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




More information about the cfe-dev mailing list