This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] cp/calls.c off by one error
- From: Sylvain Pion <Sylvain dot Pion at mpi-sb dot mpg dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Sylvain Pion <Sylvain dot Pion at mpi-sb dot mpg dot de>
- Date: Tue, 22 Apr 2003 15:11:12 +0200
- Subject: [PATCH] cp/calls.c off by one error
Current mainline prints a bogus diagnostic for a test case like the following :
-----------------
struct A {};
struct B {};
struct C {};
void f(A) {}
void f(B) {}
int main ()
{
C c;
f(c);
}
-----------------
bug.C: In function `int main()':
bug.C:12: error: no matching function for call to `f(C&)'
bug.C:6: note: candidates are: void f(A)
bug.C:7: note: ¿ void f(B)
Note the spurious character.
I would suggest the following patch, bootstrapped on i686-pc-linux-gnu,
which indeed fixes the bug :
2003-04-22 Sylvain Pion <Sylvain dot Pion at mpi-sb dot mpg dot de>
* call.c (print_z_candidates): Off by one error.
Index: gcc/cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.377
diff -u -r1.377 call.c
--- gcc/cp/call.c 22 Apr 2003 05:44:07 -0000 1.377
+++ gcc/cp/call.c 22 Apr 2003 13:03:21 -0000
@@ -2513,7 +2513,7 @@
size_t len = gcc_gettext_width (str) + 1;
char *spaces = alloca (len);
memset (spaces, ' ', len-1);
- spaces[len] = '\0';
+ spaces[len-1] = '\0';
candidates = candidates->next;
do
--
Sylvain