namespace problem
Martin v. Loewis
martin@mira.isdn.cs.tu-berlin.de
Sun May 2 12:27:00 GMT 1999
> Date: Tue, 15 Dec 1998 13:58:09 +0100 (CET)
> The error message result is:
>
> test.cc: In function `double ** alloc<double>(int, int)':
> test.cc:41: instantiated from here
> test.cc:27: Internal compiler error 980519.
Thanks for your bug report. A patch for egcs-2.93.20 is attached
below.
1999-05-02 Martin von Löwis <loewis@informatik.hu-berlin.de>
* init.c (build_member_call): Lookup names coming from
namespace-scoped LOOKUP_EXPR.
Test case:
// Produces ICE 980519.
// Test case from Dirk Engelmann <Dirk.Engelmann@IWR.Uni-Heidelberg.De>
namespace vector {
// allocate memory for vector
template <class T>
inline T* alloc(const int aWidth)
{
// allocate memory
return new T[aWidth];
}
}
namespace matrix {
// allocate memory for matrix
template <class T>
T** alloc(const int aWidth,const int aHeight)
{
// allocate memory
T **mat = vector::alloc<T*>(aHeight);
T *data = vector::alloc<T> (aWidth*aHeight);
// set pointer
for (int i=0; i<aHeight; i++)
mat[i] = &data[aWidth*i];
// ok
return mat;
}
}
main(void)
{
// sample
double **m=matrix::alloc<double>(10,20);
}
Index: init.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/init.c,v
retrieving revision 1.97
diff -u -p -r1.97 init.c
--- init.c 1999/04/29 08:33:45 1.97
+++ init.c 1999/05/02 18:34:25
@@ -1366,7 +1366,18 @@ build_member_call (type, name, parmlist)
{
/* 'name' already refers to the decls from the namespace, since we
hit do_identifier for template_ids. */
- my_friendly_assert (is_overloaded_fn (TREE_OPERAND (name, 0)), 980519);
+ method_name = TREE_OPERAND (name, 0);
+ /* FIXME: Since we don't do independent names right yet, the
+ name might also be a LOOKUP_EXPR. Once we resolve this to a
+ real decl earlier, this can go. This may happen during
+ tsubst'ing. */
+ if (TREE_CODE (method_name) == LOOKUP_EXPR)
+ {
+ method_name = lookup_namespace_name
+ (type, TREE_OPERAND (method_name, 0));
+ TREE_OPERAND (name, 0) = method_name;
+ }
+ my_friendly_assert (is_overloaded_fn (method_name), 980519);
return build_x_function_call (name, parmlist, current_class_ref);
}
More information about the Gcc-bugs
mailing list