Topic: Exception-Specification and void
Author: rphorvic@gloria.cord.edu (Robert Horvick)
Date: 1998/05/04 Raw View
After a recent discussion in this forum where I posted my idea to the
of the advertised throw specification (eg: throw(Foo, ...)
I suggested what I have found legal:
throw(Foo, void)
which acts as no exception-specification as it allows any exception to be
thrown (MSVC++ 5.0 and g++ 2.7.2.2 are my tested platforms) but also
allows a visual cue as to the primary exceptions - though serves no other
useful purpose.
My question is:
if:
void FuncName(void) {}
is the same as:
void FuncName() {}
then why is:
void FuncName(void) throw(void) {}
the same as
void FuncName() {}
and not the same as
void FuncName() throw() {}
It seems an unintutitive way for this to be handled. If, as Stroustrup
says in TC++PL 3rd, 5th. (page 76) "it [void] can, however, be used only
as part of a more complicated type, there are no objects of type void."
then shouldn't this generate a compile time error - just as if I had
tried to throw(FooException) and had not decl. a class FooException?
I have tried scouring the draft and TC++PL for info on this topic but
haven't found an adequate answer. Could someone elaborate as to whether
my compilers are broken or whether the behaivor (as I suspect) is deemed
to be undefined?
Robert Horvick
+-----------------------+----------------------------------------+
| Robert P. Horvick | http://www.cord.edu/homepages/rphorvic |
| Great Plains Software | Concordia College, Computer Science |
| rhorvick@acm.org | calloc(1, sizeof(geek)); |
+-----------------------+----------------------------------------+
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1998/05/05 Raw View
In article bgs@sonic.cord.edu, rphorvic@gloria.cord.edu (Robert Horvick) writes:
>After a recent discussion in this forum where I posted my idea to the
>of the advertised throw specification (eg: throw(Foo, ...)
>I suggested what I have found legal:
>
>throw(Foo, void)
Some compilers might accept this construct, but it is not valid
according to the C++ draft standard.