public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de> To: gcc-gnats@gcc.gnu.org Subject: c++/9128: Typeid does not work on polymorphic classes Date: Thu, 02 Jan 2003 13:06:00 -0000 [thread overview] Message-ID: <200301021403.PAA00991@snake.iap.physik.tu-darmstadt.de> (raw) >Number: 9128 >Category: c++ >Synopsis: Typeid does not work on polymorphic classes >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Thu Jan 02 05:06:02 PST 2003 >Closed-Date: >Last-Modified: >Originator: Peter Schmid >Release: 3.4 20021231 (experimental) >Organization: LBNL >Environment: System: Linux kiste 2.4.18 #10 Thu Dec 26 00:47:26 CET 2002 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: >Description: Gcc 3.4 does no longer accept the legal source code t.C. It does compile if the base class A is not polymorphic, i.e., if the destructor is not declared as virtual. >How-To-Repeat: source code t.C #include <typeinfo> struct A { virtual ~A() {} }; int main() { A* a = new A; typeid(*a).name(); } Compiling t.C g++ -v t.C -W -Wall -save-temps Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs Configured with: Thread model: posix gcc version 3.4 20021231 (experimental) /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/cc1plus -E -D__GNUG__=3 -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=4 -D__GNUC_PATCHLEVEL__=0 -D_GNU_SOURCE t.C -W -Wall t.ii ignoring nonexistent directory "NONE/include" ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/local/include/c++/3.4 /usr/local/include/c++/3.4/i686-pc-linux-gnu /usr/local/include/c++/3.4/backward /usr/local/include /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/include /usr/include End of search list. /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/cc1plus -fpreprocessed t.ii -quiet -dumpbase t.C -auxbase t -W -Wall -version -o t.s GNU C++ version 3.4 20021231 (experimental) (i686-pc-linux-gnu) compiled by GNU C version 3.4 20021231 (experimental). t.C: In function `int main()': t.C:9: error: request for member `std::type_info::name() const' in ` __cxa_bad_typeid()()', which is of non-class type `const std::type_info&' Preprocessed source code t.ii # 1 "t.C" # 1 "<built-in>" # 1 "<command line>" # 1 "t.C" # 1 "/usr/local/include/c++/3.4/typeinfo" 1 3 # 38 "/usr/local/include/c++/3.4/typeinfo" 3 # 1 "/usr/local/include/c++/3.4/exception" 1 3 # 40 "/usr/local/include/c++/3.4/exception" 3 extern "C++" { namespace std { # 52 "/usr/local/include/c++/3.4/exception" 3 class exception { public: exception() throw() { } virtual ~exception() throw(); virtual const char* what() const throw(); }; class bad_exception : public exception { public: bad_exception() throw() { } virtual ~bad_exception() throw(); }; typedef void (*terminate_handler) (); typedef void (*unexpected_handler) (); terminate_handler set_terminate(terminate_handler) throw(); void terminate() __attribute__ ((__noreturn__)); unexpected_handler set_unexpected(unexpected_handler) throw(); void unexpected() __attribute__ ((__noreturn__)); # 100 "/usr/local/include/c++/3.4/exception" 3 bool uncaught_exception() throw(); } namespace __gnu_cxx { # 115 "/usr/local/include/c++/3.4/exception" 3 void __verbose_terminate_handler (); } } # 39 "/usr/local/include/c++/3.4/typeinfo" 2 3 extern "C++" { namespace __cxxabiv1 { class __class_type_info; } # 55 "/usr/local/include/c++/3.4/typeinfo" 3 namespace std { class type_info { public: virtual ~type_info(); private: type_info& operator=(const type_info&); type_info(const type_info&); protected: const char *__name; protected: explicit type_info(const char *__n): __name(__n) { } public: const char* name() const { return __name; } # 101 "/usr/local/include/c++/3.4/typeinfo" 3 bool before(const type_info& __arg) const { return __name < __arg.__name; } bool operator==(const type_info& __arg) const { return __name == __arg.__name; } bool operator!=(const type_info& __arg) const { return !operator==(__arg); } public: virtual bool __is_pointer_p() const; virtual bool __is_function_p() const; virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, unsigned __outer) const; virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target, void **__obj_ptr) const; }; class bad_cast : public exception { public: bad_cast() throw() { } virtual ~bad_cast() throw(); }; class bad_typeid : public exception { public: bad_typeid () throw() { } virtual ~bad_typeid() throw(); }; } } # 2 "t.C" 2 struct A { virtual ~A() {} }; int main() { A* a = new A; typeid(*a).name(); } >Fix: >Release-Note: >Audit-Trail: >Unformatted:
reply other threads:[~2003-01-02 13:06 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200301021403.PAA00991@snake.iap.physik.tu-darmstadt.de \ --to=schmid@snake.iap.physik.tu-darmstadt.de \ --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).