https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121966
Bug ID: 121966
Summary: Problems with candidate numbering in
print_z_candidates
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dmalcolm at gcc dot gnu.org
Target Milestone: ---
I updated print_z_candidates in r15-6116-gd3dd24acd74605 to show the number of
candidates, and a number for each candidate.
Looking at src/gcc/testsuite/g++.dg/cpp0x/implicit15.C, I see:
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:11:5: error: use of deleted
function ‘B::B(...) [inherited from A]’
11 | } b{3}; // { dg-error "use of deleted function" }
| ^
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:9:12: note: ‘B::B(...)
[inherited from A]’ is implicitly deleted because the default definition would
be ill-formed:
9 | using A::A; // { dg-error "is ambiguous" }
| ^
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:9:12: error: call of
overloaded ‘A()’ is ambiguous
• there are 4 candidates
• candidate 1: ‘A::A()’
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:6:3:
6 | A (); // { dg-message "candidate" }
| ^
• candidate 2: ‘A::A(...)’
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:5:3:
5 | A (...); // { dg-message "candidate" }
| ^
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:11:5: note: use
‘-fdiagnostics-all-candidates’ to display considered candidates
11 | } b{3}; // { dg-error "use of deleted function" }
| ^
Note the "there are 4 candidates", followed by just 2 candidates.
I tried the hint in the note, adding -fdiagnostics-all-candidates, and the
output got more confusing:
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:11:5: error: use of deleted
function ‘B::B(...) [inherited from A]’
11 | } b{3}; // { dg-error "use of deleted function" }
| ^
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:9:12: note: ‘B::B(...)
[inherited from A]’ is implicitly deleted because the default definition would
be ill-formed:
9 | using A::A; // { dg-error "is ambiguous" }
| ^
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:9:12: error: call of
overloaded ‘A()’ is ambiguous
• there are 4 candidates
• candidate 1: ‘A::A()’
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:6:3:
6 | A (); // { dg-message "candidate" }
| ^
• candidate 2: ‘A::A(...)’
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:5:3:
5 | A (...); // { dg-message "candidate" }
| ^
• there are 5 candidates
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:11:5:
11 | } b{3}; // { dg-error "use of deleted function" }
| ^
• candidate 1: ‘A::A(...)’
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:5:3:
5 | A (...); // { dg-message "candidate" }
| ^
• inherited here
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:9:12:
9 | using A::A; // { dg-error "is ambiguous" }
| ^
• candidate 2: ‘constexpr A::A(const A&)’
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:4:8:
4 | struct A {
| ^
• inherited here
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:9:12:
9 | using A::A; // { dg-error "is ambiguous" }
| ^
• an inherited constructor is not a candidate for initialization from an
expression of the same or derived type
• candidate 3: ‘constexpr A::A(A&&)’
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:4:8:
4 | struct A {
| ^
• inherited here
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:9:12:
9 | using A::A; // { dg-error "is ambiguous" }
| ^
• an inherited constructor is not a candidate for initialization from an
expression of the same or derived type
• candidate 4: ‘constexpr B::B(const B&)’
../../src/gcc/testsuite/g++.dg/cpp0x/implicit15.C:8:8:
8 | struct B : A {
| ^
• no known conversion for argument 1 from ‘int’ to ‘const B&’
• candidate 5: ‘constexpr B::B(B&&)’
• no known conversion for argument 1 from ‘int’ to ‘B&&’
where it's still showing "there are 4 candidates" and then listing just 2, and
then showing an additional "there are 5 candidates", albeit with more
candidates.
Affects GCC 15; see https://godbolt.org/z/9a1z49zvf