The attached stuff is a patch for PR9399: http://sourceware.org/bugzilla/show_bug.cgi?id=9399 "gdb can't call or print a const function that uses virtual inheritance" The bug was in valops.c:value_cast_structs() which could do spurious upcasts or downcasts. The fix tests whether any casts at all are necessary and, if not, returns a NULL. The patch hits two ChangeLogs, one for the fix, in .../gdb/ChangeLog, the other for the testcase in gdb/testsuite/ChangeLog. Respectively, they are: 2009-12-08 Chris Moller PR gdb/9399 * valops.c (value_cast_structs): Added test to return NULL if no casting needed. 2009-12-08 Chris Moller PR gdb/9399 * gdb.cp/virtfunc2.exp: * gdb.cp/virtfunc2.cc: New tests for a patch to fix PR gd/9399 * gdb.cp/Makefile.in: Added tests to EXECUTABLES (These are both included in the attached patch file.) The patch file includes the patch to gdb/valops.c, gdb/ChangeLog, gdb/testsuite/ChangeLog, gdb/testsuite/gdb.cp/Makefile.in, and mc-log.diffs. (The patch to Makefile.in is to incorporate the testcase for 'make check'; mc-log.diffs are the diffs between before and after runs of 'make check') I can't do a 'cvs add' so the the testcase expects and .cc file are attached separately as gdb/testsuite/gdb.cp/virtfunc2.cc and gdb/testsuite/gdb.cp/virtfunc2.exp. You can see what the patch does by compiling -g virtfunc.cc, gdb-ing it, breaking in the return stmt at // marker1, and doing things like "print o.do_print()". Without the patch, gdb tries to access location 0x0; with the patch it does the right thing. (There are more tests in virtfunc2.exp) I've included the diff between the before and after 'make check' logs. I don't think the patch breaks anything--most of the diffs are with respect to the different directories used for before and after builds. Starting at line 131 in mc-log.diffs, you can see the new tests, virtfunc2, and, following that, the six new expected passes. I've assigned that bug to myself. If you're happy with the patch, let me know and I'll close the bug. (Or do whatever you usually do...) Have fun, Chris Moller Red Hat