[Bug c++/93710] poor location in diagnostics of messages about array initializers
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Feb 12 17:25:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93710
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
With
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4172,8 +4172,9 @@ build_user_type_conversion_1 (tree totype, tree expr, int
flags,
if (complain & tf_error)
{
auto_diagnostic_group d;
- error ("conversion from %qH to %qI is ambiguous",
- fromtype, totype);
+ error_at (EXPR_LOCATION (expr),
+ "conversion from %qH to %qI is ambiguous",
+ fromtype, totype);
print_z_candidates (location_of (expr), candidates);
}
we print
93710.C:6:3: error: conversion from ‘long int’ to ‘A’ is ambiguous
6 | 0L,
| ^~
93710.C:1:21: note: candidate: ‘A::A(char*)’
1 | struct A { A (int); A (char*); int i; };
| ^
93710.C:1:12: note: candidate: ‘A::A(int)’
1 | struct A { A (int); A (char*); int i; };
| ^
which seems much better.
More information about the Gcc-bugs
mailing list