Fix latent bug in c++ frontend
Josef Zlomek
zlomj9am@artax.karlin.mff.cuni.cz
Thu Jan 16 18:18:00 GMT 2003
Hi,
this patch probably fixes a bug in C++ frontend which caused segfault.
It appeared when compiling gtkmm, I have destiled attached testcase from it.
I am not familiar with C++ frontend code so the patch may be wrong,
can someone who understand C++ frontend check it?
template <class T>
inline T* manage(T* t)
{
return t;
}
template <class R>
struct ObjectSlot0_
{
static void create()
{
manage(new int);
}
};
The problem is with "new anytype" in a templated function call.
The attached patch fixes the segfault.
When I changed "new int" to "new int[4]" I got:
xx.i:12: internal compiler error: tree check: expected class 't',
have 'x' (tree_list) in cp_parser_dependent_type_p, at cp/parser.c:1859
I do not know how to fix it, but such a construction is probably not
used in majority of software packages.
Bootstrapped mainline i386 (athlon), running regtests now.
Josef
2003-01-16 Josef Zlomek <zlomekj@suse.cz>
* decl2.c (arg_assoc): If code of tree is NEW_EXPR assoc type
of the first parameter.
*** gcc-main.bug/gcc/cp/decl2.c 2003-01-16 09:03:26.000000000 +0100
--- gcc-main.fix/gcc/cp/decl2.c 2003-01-16 17:18:11.000000000 +0100
*************** arg_assoc (struct arg_lookup *k, tree n)
*** 4037,4042 ****
--- 4037,4045 ----
if (TYPE_P (n))
return arg_assoc_type (k, n);
+ if (TREE_CODE (n) == NEW_EXPR)
+ return arg_assoc_type (k, TREE_OPERAND (n, 1));
+
if (! type_unknown_p (n))
return arg_assoc_type (k, TREE_TYPE (n));
More information about the Gcc-patches
mailing list