infinite loop in gcc/cp/decl.c

Smithers, Kit kit.smithers@eds.com
Tue Dec 7 07:52:00 GMT 1999


I'm having trouble with gcc seeming to enter an infinite loop. I have some
speculative considerations as to what may be wrong but I'm aware that I
might be completely fooled by what's happening.

It happens in cc1plus in the module gcc/cp/decl.c

line 12480. just after the comment: /* 13.4.0.8 */

The for loop here checks against "void_list_node" to see if the loop should
terminate:

for (; argtypes != void_list_node ; argtypes = TREE_CHAIN (argtypes))

This is unlike any other loop in decl.c which uses TREE_CHAIN to get the
next item. They all check for the pointer not being 0. 

When I stop cc1plus in gdb I can see that:

(gdb) p argtypes
$5 = 0x0
(gdb) p argtypes->common.chain
$6 = (union tree_node *) 0x0
(gdb) p void_list_node
$7 = 0x200580b8

I believe TREE_CHAIN(NODE) is ((NODE)->common.chain) as defined in
gcc/tree.h

So the loop is going to go on forever.

The code I'm passing in has been through two levels of preprocessing
(Cantata++ and Insure++) which makes it difficult for me to isolate the code
that's causing the problem since it doesnt occur in the unprocessed
original. But from looking at the way this loop is coded it doesn't seem to
me that it covers the possibility of "argtypes == 0" as an escape condition
for the loop. As I said other loops in the same file either check for not
null and in some cases checks are made for void_list_node as well.

So my question is:

would it be _correct_ for me to amend the for loop to check for 'argtypes !=
0' as well as void_list_node ?

-- 
Kit Smithers


More information about the Gcc-bugs mailing list