cigien
cigien

Reputation: 60268

Redundant parentheses in the declarator of a variable with deduced class template specialization type

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?

Upvotes: 4

Views: 332

Answers (1)

Davis Herring
Davis Herring

Reputation: 40013

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.

Upvotes: 1

Related Questions