]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: fix count of z candidates for non-viable candidates, nesting [PR121966]
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 17 Sep 2025 20:39:31 +0000 (16:39 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 17 Sep 2025 20:39:31 +0000 (16:39 -0400)
In r15-6116-gd3dd24acd74605 I updated print_z_candidates to show the
number of candidates, and a number for each candidate.

PR c++/121966 notes that the printed count is sometimes higher than
what's actually printed: I missed the case where candidates in the
list aren't printed due to not being viable.

Fixed thusly.

gcc/cp/ChangeLog:
PR c++/121966
* call.cc (print_z_candidates): Copy the filtering logic on viable
candidates from the printing loop to the counting loop, so that
num_candidates matches the number of iterations of the latter
loop.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/cp/call.cc

index 02cef63a453824875be9ca03e6f402ee42d3a61b..d11961a48ada48672c978c74a8d711a302d812f2 100644 (file)
@@ -4255,7 +4255,11 @@ print_z_candidates (location_t loc, struct z_candidate *candidates,
 
   int num_candidates = 0;
   for (auto iter = candidates; iter; iter = iter->next)
-    ++num_candidates;
+    {
+      if (only_viable_p.is_true () && iter->viable != 1)
+       break;
+      ++num_candidates;
+    }
 
   inform_n (loc,
            num_candidates, "there is %i candidate", "there are %i candidates",