This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: throw specs on Standard destructors
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: Kenny Simpson <theonetruekenny at yahoo dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Tue, 10 Dec 2002 12:41:08 -0600
- Subject: Re: throw specs on Standard destructors
- References: <20021208034905.76280.qmail@web20009.mail.yahoo.com>
>#include <string>
>
>struct Base
>{
> virtual ~Base() throw() {}
>};
>
>struct Der : Base
>{
> std::string foo;
>};
>
>int main()
>{
> Der d;
>}
Ouch.
>The problem here is that the default destructor for
>Der will have a throw spec which is the union of all
>bases and members. Since std::basic_string has no
>throw spec, Der::~Der also will have none, which
>violates Base's destructor's spec.
%g++ simpson.cc
simpson.cc:9: looser throw specifier for `virtual Der::~Der()'
simpson.cc:5: overriding `virtual Base::~Base() throw ()'
simpson.cc:9: looser throw specifier for `virtual Der::~Der()'
simpson.cc:5: overriding `virtual Base::~Base() throw ()'
simpson.cc:9: looser throw specifier for `virtual Der::~Der()'
simpson.cc:5: overriding `virtual Base::~Base() throw ()'
>My local work-around was to add the empty throw spec
>to basic_string, but I'm not clear if this is an
>ABI-breaking change, or if there is some other
>subtlety here. I can't find the ABI FAQ for this.
Well, I've added it too, and then run 'make check-abi', which seem to
indicate that this is not an ABI breaking change, at least at the
exported symbol level.
15.4 - Exception specifications p12 also supports this.
As you've indicated, it would change the interface. I believe this is
explicitly allowd via
17.4.4.8 - Restrictions on exception handling p 3.
>I would assume the same should be done for auto_ptr.
Where would it stop? That part is unclear to me.
I think patches of this type are acceptable. Interested?
-benjamin