public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: abramsh@acm.org To: gcc-gnats@gcc.gnu.org Subject: c++/3993: dynamic_cast<>() fails in simple test case w/ dynamic loading Date: Fri, 10 Aug 2001 22:56:00 -0000 [thread overview] Message-ID: <20010811055240.27212.qmail@sourceware.cygnus.com> (raw) >Number: 3993 >Category: c++ >Synopsis: dynamic_cast<>() fails in simple test case w/ dynamic loading >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Aug 10 22:56:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Howard Abrams >Release: gcc version 3.0 >Organization: >Environment: Linux blah.voidstar.org 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown on i686-pc-linux-gnu >Description: When using "dlopen" to load a library, gcc seems to NOT merge type_info symbols from the library. The result is dynamic casts fail, as well as type_info::operator== for object that they should not fail on. Below is simple source to reproduce this problem. Also note that on version 2.96 (Red Hat Linux 7.1 2.96-81) (I know, you don't support that... ) this works fine. >How-To-Repeat: To reproduce this there are three small files. Compile with the following two lines: g++ -g -o test2.so -shared test2.cpp g++ -g -o testcase test.cpp -ldl The files are as follows: classb.h ======== struct a { virtual ~a() {} }; struct b : public a { virtual ~b() {} }; test2.cpp ========= #include <typeinfo> #include "classb.h" extern "C" { a *getnewb() { return new b; } const std::type_info &gettypeb() { return typeid( b ); } } test.cpp ======== #include <dlfcn.h> #include <typeinfo> #include <cassert> #include "classb.h" int main() { a *(*func)(void); const std::type_info &(*type)(void); void *handle = dlopen( "test2.so", RTLD_NOW ); func = (a *(*)(void))dlsym( handle, "getnewb" ); type = (const std::type_info &(*)(void))dlsym( handle, "gettypeb" ); a *a_ptr = (*func)(); const std::type_info &t = (*type)(); assert ( dynamic_cast<b*>( a_ptr ) ); assert ( typeid( b ) == t ); } >Fix: >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2001-08-10 22:56 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-08-10 22:56 abramsh [this message] 2001-11-08 21:06 sirl 2001-11-08 22:56 sirl 2001-12-04 6:55 nathan 2001-12-04 6:56 nathan
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=20010811055240.27212.qmail@sourceware.cygnus.com \ --to=abramsh@acm.org \ --cc=gcc-gnats@gcc.gnu.org \ /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).