public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: aristovski@qnx.com To: gdb-gnats@sources.redhat.com Subject: c++/2416: casting to reference type causes internal error Date: Wed, 27 Feb 2008 17:58:00 -0000 [thread overview] Message-ID: <20080227174847.32383.qmail@sourceware.org> (raw) >Number: 2416 >Category: c++ >Synopsis: casting to reference type causes internal error >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Feb 27 17:58:01 UTC 2008 >Closed-Date: >Last-Modified: >Originator: aristovski@qnx.com >Release: 6.7 >Organization: >Environment: linux >Description: When casting to a reference type, gdb_assert is triggered causing internal error. >How-To-Repeat: Use the following to create files main.cc and init === main.cc === #include <cstdlib> #include <iostream> using namespace std; namespace IP { class base { public: base () { cout << "Base class\n"; } virtual void foo() {} }; class derived: public base { public: derived () { cout << "Derived class\n"; derivedfield = 42; } void foo() { cout << "derived::foo" << endl; } int derivedfield; }; } void testCast1 (IP::base & arg) { cout << "Test the casting\n"; arg.foo(); } void testCast2 (IP::base (&arr)[2]) { arr[0].foo(); arr[1].foo(); } void testCast3 (IP::base *(&arr)[2]) { arr[0]->foo(); arr[1]->foo(); } int main(int argc, char *argv[]) { IP::base a[] = { IP::derived(), IP::base() }; IP::base *d = new IP::derived(); IP::base * basder[] = { new IP::derived(), new IP::base() }; testCast1(*d); testCast2(a); testCast3(basder); return 1; } ================ === file init === file main b testCast1 b testCast2 b testCast3 r print ('IP::derived' &) arg echo "I'm still alive..." c ================= now compile main.cc: g++ -g -o main main.cc Finally, run gdb -x init >Fix: >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2008-02-27 17:58 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-02-27 17:58 aristovski [this message] 2008-04-01 17:31 aristovski
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20080227174847.32383.qmail@sourceware.org \ --to=aristovski@qnx.com \ --cc=gdb-gnats@sources.redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).