This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Problems with exception handling in 2.96 snapshots
- To: Max Weninger <max at takefive dot co dot at>
- Subject: Re: Problems with exception handling in 2.96 snapshots
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Fri, 25 Feb 2000 12:06:48 +0000
- CC: gcc-bugs at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <200002251103.MAA07786@extreme.takefive.co.at>
Max Weninger wrote:
>
> Hi,
>
> I just discovered the following behaviour with the latetet 2.96 snapshot
>
> class A {
> public:
> A( ){;}
> ~A( ){;}
> void test( ) throw( A );
> };
>
> When i try to compile this code the following errors came up
>
> x.C:5: invalid use of undefined type `class A'
> x.C:1: forward declaration of `class A'
>
> The same worked with all older versions e.g. 2.95.2
>
> Whats wrong ?
Your code :-) Arguably c++.
[9.2]/2 says that within the definition of a class, the class is considered
complete within function bodies, default args & ctor initializers. Elsewhere
it is incomplete. Therefore it is incomplete in a member function prototype, and
the exception specifier.
[8.3.5]/6 says that the type of a parameter or the return type for a function
declaration that is not a definition may be an incomplete type. (I can't find
where it says a declaration which is a definition must have complete type,
but I infer that from this part of the standard.)
The body of a function is the bit between { ... } ([8.4]/2
So, your throw specifier is a declaration and A is incomplete at that point.
This is annoying. However, there is a bigger problem, which looks like a defect
in the standard. Here it is
struct A {
void baz (A arg);
void foo (A arg) {}
};
void A::baz (A arg) {}
Here A::foo is a definition, so its parameters may not have incomplete type.
A::baz in A is not a definition, so its parameters may have incomplete type.
The definition of A::baz is after the definition of A, so A is complete.
I don't think compilers actually implement that, but it's what the words say.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org