Topic: Where are exception specs allowed


Author: John Lilley <jlilley@empathy.com>
Date: 1997/03/06
Raw View
Gerd Moellmann wrote:
>
> In CD2, paragraph except.spec/1 contains thte sentence
> > An exception-specification shall appear only on a function  declarator
> > in  a function, pointer, reference or pointer to member declaration or
> > definition.
>
> Does this mean that one cannot declare pointers to pointers to fns
> with exception specs, or arrays of pointers to fns with exception
> specs?
>         int (**pf)() throw();
>         int (*af[2])() throw();
>
> If this is true and not a bug in CD2, what's the reason? Please tell
> me it's a bug...

The way I read it, yes.  The reason, as far as I can tell, comes from
paragraph 12 in that section:

"An exception-specification is not considered part of a function's type"

Since the exception-specification is not part of the type, it is
pointless to include the exception-specification in contexts that are
only using the type of the function.  But that language is inconsisent
with the language that says the exception-specification of
pointers-to-functions *is* meaningful, and must be checked during
assignment from one function-pointer to another.  IMHO it was a mistake
to exclude the exception-specification from the type of the function.
Making the exception-specification part of the function type would have
made things more consistent.

In particular, this is a problem:

    void f_throw() throw(int);
    void f_nothrow();
    void (*fp_nothrow)();
    void (*fp_throw)() throw (int);
    void (**fpp)();

    fp_nothrow = f_throw;    // (1) OK, less restrictive
    fp_throw = f_nothrow;    // (2) error, more restrictive
    fpp = &fp_nothrow;       // (3) OK??  double-indirection has
                             // no exception-specification.
    fp_throw = *fpp;         // OK?? Didn't this defeat (2)?

Perhaps someone can send this to the committee.

john lilley
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Gerd Moellmann <gerd@acm.org>
Date: 1997/03/03
Raw View
In CD2, paragraph except.spec/1 contains thte sentence

> An exception-specification shall appear only on a function  declarator
> in  a function, pointer, reference or pointer to member declaration or
> definition.

Does this mean that one cannot declare pointers to pointers to fns
with exception specs, or arrays of pointers to fns with exception
specs?

 int (**pf)() throw();
 int (*af[2])() throw();

If this is true and not a bug in CD2, what's the reason? Please tell
me it's a bug...

--
Gerd Moellmann, Altenbergstr. 6, D-40235 Duesseldorf, Germany
tel: +49 211 666 881, mailto: gerd@acm.org
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]