From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3772 invoked by alias); 9 Sep 2010 12:50:30 -0000 Received: (qmail 3754 invoked by uid 22791); 9 Sep 2010 12:50:28 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_05 X-Spam-Check-By: sourceware.org Received: from imr4.ericy.com (HELO imr4.ericy.com) (198.24.6.8) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Sep 2010 12:50:17 +0000 Received: from eusaamw0712.eamcs.ericsson.se ([147.117.20.181]) by imr4.ericy.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id o89CxXQL001904 for ; Thu, 9 Sep 2010 07:59:35 -0500 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.10]) by eusaamw0712.eamcs.ericsson.se ([147.117.20.181]) with mapi; Thu, 9 Sep 2010 08:50:08 -0400 From: Marc Khouzam To: "'gdb@sourceware.org'" Date: Thu, 09 Sep 2010 12:50:00 -0000 Subject: GDB syntax error when casting to base class Message-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-09/txt/msg00055.txt.bz2 Hi, I got an eclipse bug report that led me to a bizarre behavior from GDB. In the very short session below, I'm getting a syntax error when casting a variable to its base class. If I remove the constructor (see comment in the code below) the problem goes away. Or if I add the word 'struct', it also goes away. This is causing problems in Eclipse because -var-info-path-expression returns the expression that causes a syntax error. I tried to debug it but I ended up in c-exp.y and had to give up. I was going to propose a patch that adds 'struct' to the=20 -var-info-path-expression output, but I didn't think that was the=20 greatest of solutions. Currently, this is what we are planning to=20 do in Eclipse to work around this problem. I can open a PR if it makes sense? Thanks Marc > gdb.7.2 a.out GNU gdb (GDB) 7.2 (gdb) l 1 1 class bar{}; 2 3 class foo : public bar { 4 public: 5 foo() {} // Comment this line to make things work 6 void test() { return; } 7 }; 8 9 int main(void) 10 { 11 foo f; 12 f.test(); 13 return 0; 14 } (gdb) b 6 Breakpoint 1 at 0x8048457: file base.cc, line 6. (gdb) r Starting program: /local/lmckhou/testing/a.out=20 Breakpoint 1, foo::test (this=3D0xbfffbfa3) at base.cc:6 6 void test() { return; } (gdb) p (*(bar*) this) A syntax error in expression, near `) this)'. (gdb) p (*(struct bar*) this) $1 =3D {}