From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31153 invoked by alias); 21 Aug 2002 06:11:29 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 31146 invoked from network); 21 Aug 2002 06:11:28 -0000 Received: from unknown (HELO zenia.red-bean.com) (66.244.67.22) by sources.redhat.com with SMTP; 21 Aug 2002 06:11:28 -0000 Received: (from jimb@localhost) by zenia.red-bean.com (8.11.6/8.11.6) id g7L60qD29529; Wed, 21 Aug 2002 01:00:52 -0500 Date: Tue, 20 Aug 2002 23:11:00 -0000 Message-Id: <200208210600.g7L60qD29529@zenia.red-bean.com> From: Jim Blandy To: gdb-patches@sources.redhat.com Subject: RFA: static cast from base class to derived class X-SW-Source: 2002-08/txt/msg00656.txt.bz2 Once when my grandfather was a boy, he was riding his bicycle along a gravel path, and going pretty fast, when he hit a stone, went flying over the handlebars, and landed on his face. The gravel was ground so deeply into his face that, even in his forties, he'd still occasionally encounter, while shaving, bits of rock that had finally worked their way out to the surface. Here's a patch for a bit of 1998 HP Merge gravel that has finally found its way to the surface. I didn't see any regressions with this patch using either STABS or Dwarf 2. I'll put together a regression test for the original bug tomorrow. 2002-08-20 Jim Blandy * valops.c (value_cast): Simplify and correct logic for doing a static cast from a pointer to a base class to a pointer to a derived class. Index: gdb/valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.67 diff -c -r1.67 valops.c *** gdb/valops.c 19 Aug 2002 23:19:53 -0000 1.67 --- gdb/valops.c 21 Aug 2002 02:42:21 -0000 *************** *** 361,378 **** value_zero (t1, not_lval), 0, t1, 1); if (v) { ! struct value *v2 = value_ind (arg2); ! VALUE_ADDRESS (v2) -= VALUE_ADDRESS (v) ! + VALUE_OFFSET (v); ! ! /* JYG: adjust the new pointer value and ! embedded offset. */ ! v2->aligner.contents[0] -= VALUE_EMBEDDED_OFFSET (v); ! VALUE_EMBEDDED_OFFSET (v2) = 0; ! ! v2 = value_addr (v2); ! VALUE_TYPE (v2) = type; ! return v2; } } } --- 361,371 ---- value_zero (t1, not_lval), 0, t1, 1); if (v) { ! CORE_ADDR addr2 = value_as_address (arg2); ! addr2 -= (VALUE_ADDRESS (v) ! + VALUE_OFFSET (v) ! + VALUE_EMBEDDED_OFFSET (v)); ! return value_from_pointer (type, addr2); } } }