While debugging an infinite loop in gdb I found it occurred here: value_struct_elt: while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF) { *argp = value_ind (*argp); /* Don't coerce fn pointer to fn and then back again! */ if (TYPE_CODE (value_type (*argp)) != TYPE_CODE_FUNC) *argp = coerce_array (*argp); t = check_typedef (value_type (*argp)); } The comment for value_struct_elt says: /* Given *ARGP, a value of type (pointer to a)* structure/union, There's no suggestion of *ARGP being a pointer to a pointer to a pointer to ... a pointer to a struct/union. If this is an ease of use feature for the user, this seems like too low a level a routine to implement this feature. One possibility is that the loop is just a simple way to handle ptr->ref, with ptr->ptr->ptr->... being accidental fallout. IWBN to clarify this. The TYPE_CODE (value_type (*argp)) needs a call to check_typedef. Another related bug is why is there a check for a function inside the loop? We're only interested in structs/unions here. I suspect it's because coerce_array is misnamed/confusing: it also coerces functions to be pointer to functions. And if we didn't do the check we would be stuck in an infinite loop. Alas we still are in an infinite loop if *argp is ptr->typedef->func.
CVSROOT: /cvs/src Module name: src Changes by: devans@sourceware.org 2013-08-01 23:59:48 Modified files: gdb : ChangeLog valops.c gdb/testsuite : ChangeLog Added files: gdb/testsuite/gdb.base: func-ptr.c func-ptr.exp Log message: PR symtab/15695 * valops.c (value_struct_elt): Add missing call to check_typedef. (value_find_oload_method_list): Ditto. testsuite/ * gdb.base/func-ptr.exp: New file. * gdb.base/func-ptr.c: New file. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.15857&r2=1.15858 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/valops.c.diff?cvsroot=src&r1=1.314&r2=1.315 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3755&r2=1.3756 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/func-ptr.c.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/func-ptr.exp.diff?cvsroot=src&r1=NONE&r2=1.1
Fixed since gdb-7.7.