Skip to content

bad sort order for candidates #24631

@llvmbot

Description

@llvmbot
Bugzilla Link 24257
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @DougGregor

Extended Description

$ cat b16776752-1.cc
struct Y {};

struct X {
  X();
  X(const X&) = delete;
  X(const X&&) = delete;
  X(Y&);
};

void test() {
  const Y y{};
  X x2(y);
}
$ clang b16776752-1.cc -std=c++14
b16776752-1.cc:12:5: error: no matching constructor for initialization of 'X'
  X x2(y);
    ^  ~
b16776752-1.cc:5:3: note: candidate constructor not viable: no known conversion
      from 'const Y' to 'const X' for 1st argument
  X(const X&) = delete;
  ^
b16776752-1.cc:6:3: note: candidate constructor not viable: no known conversion
      from 'const Y' to 'const X' for 1st argument
  X(const X&&) = delete;
  ^
b16776752-1.cc:7:3: note: candidate constructor not viable: 1st argument
      ('const Y') would lose const qualifier
  X(Y&);
  ^
b16776752-1.cc:4:3: note: candidate constructor not viable: requires 0
      arguments, but 1 was provided
  X();
  ^
1 error generated.

The two constructors are both non-viable and deleted. The X(Y&) ctor is non-viable only by a const qualifier, so it should sort ahead of the others. The deleted ctors should probably sort last.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions