4

The following program

template <typename = int>
struct S {};

S (s);

is compiled by GCC with only a warning about the redundant parentheses around the declarator. However, Clang gives a hard error for the declaration

error: cannot use parentheses when declaring variable with deduced class template specialization type

This is quite a specific error (e.g. S<int> (s); compiles), so I guess this is intentional, but I can't find the wording that says this is ill-formed. Obvious candidates like dcl.dcl and temp.class.general don't say anything about this, unless I missed it.

Is this a GCC bug, or is it IFNDR, and Clang is being helpful?

cigien
  • 57,834
  • 11
  • 73
  • 112

1 Answers1

1

This appears to be Clang over-eagerly applying CWG2376 by prohibiting all declarator operators rather than just those that change the type declared. Heuristics for diagnosing most-vexing-parse issues might also be at play.

Davis Herring
  • 36,443
  • 4
  • 48
  • 76