This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C++ ice with overloaded functions [Second try]
- Subject: Re: [PATCH] C++ ice with overloaded functions [Second try]
- From: Theodore Papadopoulo <Theodore dot Papadopoulo at sophia dot inria dot fr>
- Date: Fri, 04 Aug 2000 19:07:17 +0200
- cc: Mark Mitchell <mark at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
[Oups. I forgot to remove some crap in my previous mail that could be
misleading]
Mark Mitchell <mark@codesourcery.com> wrote:
> Thanks for your patch. I think a different approach is in order,
> though. We shouldn't be calling arg_assoc_type for uninstantiated
> function templates -- only for ordinary functions, or for
> instantiations/specializations of function tempaltes. The
> arg_assoc_type function is used to do Koenig lookup, and I don't think
> that should be hapenning yet. Does that make sense?
Well I think I finally got the meaning of it...
I hope this new version is better.
The testcase given below (I'm not sure I named it correctly) fails with the
current version of gcc (actually 2000-08-01).
mururoa->g++ koenig9.C
koenig9.C: In function `void bar ()':
koenig9.C:12: Internal compiler error 390.
koenig9.C:12: Please submit a full bug report.
koenig9.C:12: See <URL:http://www.gnu.org/software/gcc/bugs.html> for
instructions.
The problem is that the function arg_assoc in cp/decl2.c calls the function
arg_assoc_type for uninstantiated function templates which is wrong (as pointed
out by Mark). While I was there, I also cleaned a little the function add_function
in a way slightly more logical.
With the patch provided here (I hope this time I fixed the problem at the right place), it gives:
jamaique->/net/home/robotvis/gnu/egcs/bin/g++ koenig9.C
koenig9.C: In function `void bar ()':
koenig9.C:12: address of overloaded function with no contextual type information
I have bootstrapped the compiler. Unfortunately, the current (unpatched) compiler gives me
so many regressions that claiming that this patch introduces no regressions would be meaningless.
I have to investigate what is going wrong.
New file:
gcc/testsuite/g++.old-deja/g++.ns/koenig9.C
// Build don't link:
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Theodore.Papadopoulo 23 Jun 2000 <Theodore.Papadopoulo@sophia.inria.fr>
#include <algorithm>
void foo(const char*,...);
inline void
bar() {
foo("",count); // ERROR - multiple overloaded count functions
}
ChangeLog for gcc/cp:
2000-08-04 Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr>
* decl2.c (add_function): Reorganize.
(arg_assoc): Do not consider function template decls.
Index: gcc/cp/decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.380
diff -r1.380 decl2.c
4777,4793c4777
< if (k->functions && is_overloaded_fn (k->functions)
< && is_overloaded_fn (fn))
< k->functions = build_overload (fn, k->functions);
< else if (k->functions)
< {
< tree f1 = OVL_CURRENT (k->functions);
< tree f2 = fn;
< if (is_overloaded_fn (f1))
< {
< fn = f1; f1 = f2; f2 = fn;
< }
< cp_error_at ("`%D' is not a function,", f1);
< cp_error_at (" conflict with `%D'", f2);
< cp_error (" in call to `%D'", k->name);
< return 1;
< }
< else
---
> if (!k->functions)
4794a4779,4795
> else
> if (is_overloaded_fn (k->functions) && is_overloaded_fn (fn))
> k->functions = build_overload (fn, k->functions);
> else
> {
> tree f1 = OVL_CURRENT (k->functions);
> tree f2 = fn;
> if (is_overloaded_fn (f1))
> {
> fn = f1; f1 = f2; f2 = fn;
> }
> cp_error_at ("`%D' is not a function,", f1);
> cp_error_at (" conflict with `%D'", f2);
> cp_error (" in call to `%D'", k->name);
> return 1;
> }
>
5049,5051c5050,5058
< for (; n; n = OVL_CHAIN (n))
< if (arg_assoc_type (k, TREE_TYPE (OVL_FUNCTION (n))))
< return 1;
---
> for (; n; n = OVL_CHAIN (n))
> {
> /* Do not consider function template decls during Koenig lookup. */
>
> tree fn = OVL_FUNCTION (n);
> if (!DECL_FUNCTION_TEMPLATE_P (fn)
> && arg_assoc_type (k, TREE_TYPE (fn)))
> return 1;
> }
--------------------------------------------------------------------
Theodore Papadopoulo
Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01
--------------------------------------------------------------------