public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7239: g++ rejects pointer to own class type in throw statement
@ 2002-07-09  1:16 nathan
  0 siblings, 0 replies; 2+ messages in thread
From: nathan @ 2002-07-09  1:16 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, mayer, nobody

Synopsis: g++ rejects pointer to own class type in throw statement

State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Tue Jul  9 01:16:05 2002
State-Changed-Why:
    not a bug. [15.4]/1 says this is ill formed

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7239


^ permalink raw reply	[flat|nested] 2+ messages in thread

* c++/7239: g++ rejects pointer to own class type in throw statement
@ 2002-07-08 18:36 mayer
  0 siblings, 0 replies; 2+ messages in thread
From: mayer @ 2002-07-08 18:36 UTC (permalink / raw)
  To: gcc-gnats


>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:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-09  8:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-09  1:16 c++/7239: g++ rejects pointer to own class type in throw statement nathan
  -- strict thread matches above, loose matches on Subject: below --
2002-07-08 18:36 mayer

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).