Skip to content

Clang accepts invalid parenthesized constructor declarator #152018

@zygoloid

Description

@zygoloid

Per [class.ctor.general]/1, a constructor declarator cannot be parenthesized:

struct A {
  // OK, constructor
  (A)(int);

  // Error, not a constructor due to enclosing parens.
  (A(float));
};
// OK, constructor
(A::A(int)) {}
// Error, not a constructor due to enclosing parens.
(A::A(float)) {}

But Clang accepts anyway, as do all other major compilers. We should reject under -pedantic-errors, but given the widespread support it probably makes sense to continue to accept this by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions