public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: mayer@tux.org To: gcc-gnats@gcc.gnu.org Subject: c++/7239: g++ rejects pointer to own class type in throw statement Date: Mon, 08 Jul 2002 18:36:00 -0000 [thread overview] Message-ID: <200207090128.SAA04656@hydra.hnc.com> (raw) >Number: 7239 >Category: c++ >Synopsis: g++ rejects pointer to own class type in throw statement >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Mon Jul 08 18:36:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: >Release: 3.0.2 >Organization: tux.org >Environment: System: SunOS hydra 5.6 Generic_105181-16 sun4u sparc SUNW,Ultra-2 Architecture: sun4 host: sparc-sun-solaris2.6 build: sparc-sun-solaris2.6 target: sparc-sun-solaris2.6 configured with: ../gcc/configure --prefix=/work/hyd01/td/sw/gcc_3_0_2_release --disable-nls --disable-threads --disable-shared --enable-languages=c,c++,f77,objc >Description: G++ does not compile any class that has a pointer to its own class type as an exception type in the throw specification of a member function. >How-To-Repeat: Assume the file bug.cc contains the following three lines: struct X { void f() throw (X*) { throw this;} }; Then the command "g++ -c bug.cc" creates the error message bug.cc:2: invalid use of undefined type `struct X' bug.cc:1: forward declaration of `struct X' "g++ -c -E bug.cc" reports: # 1 "bug.cc" struct X { void f() throw (X*) { throw this;} }; >Fix: Do not have one. Work-around: Use a wrapper class, as in: struct X; struct Y { Y(const X * x) : xp(x) {} const X * xp; }; struct X { void f() throw (Y) { throw Y(this);} }; This compiles fine. >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-07-09 1:36 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-07-08 18:36 mayer [this message] 2002-07-09 1:16 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=200207090128.SAA04656@hydra.hnc.com \ --to=mayer@tux.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).