This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: exception specifications
Martin v. Loewis wrote:
> Taking the text of the standard literally, I'd agree that g++ is in
> error. However, it seems that paragraph is poorly worded, so I think
> we should clarify it first before taking action.
>
> > Looking at fn3, that is throwing type 'Y *', yet the exception
> > specification is 'X const * const', that's not an X or X *, so
> > shouldn't the final sentance of 15.4/7 apply (exact match)?
>
> It seems they've totally forgotten about cv qualifiers in that
> paragraph.
Yup, that's what I think. Elsewhere the standard is quite careful to mention
whether cv qualifiers are not important. Here it is quite clearly talking about
'class X' and 'class Y *'.
> Consider
>
> struct Y{};
> struct Z:Y{
> static Z const* make_z();
> };
>
> void foo()throw(Y const*)
> {
> throw Z::make_z();
> }
>
> Should that call unexpected()? I think the spirit of the spec says it
> shouldn't, yet the words say it should, since it is not a pointer of
> the form Y* (for a class Y).
I agree.
Ignoring the cv-quals here makes checking a throw through an exceptions
specifier the same as checking catch clauses (15.3/3). I believe that's what
most users would expect (I sure did, until I went over it with a microscope).
Not ignoring the cv quals makes top-level qualified cv qualified exception
specs useless -- it's impossible to throw a `Y *const' for instance. Not
ignoring first level cv quals gives the perversity of your example.
I'll implement the more relaxed behaviour (and take this query to comp.std.c++)
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
You can up the bandwidth, but you can't up the speed of light
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk