Compilers that do implement C++ Exception Specifications

  • Thread starter Philipp Holzschneider
  • Start date
P

Philipp Holzschneider

Are there any available c++ compilers around that strictly
implement the mentioned "Exception Specification"
feature??


where the following compiles
void func() { throw A(); };
void gunc() throw(A,B) { throw A(); };
----
void thrower() throw(A) { throw A(); };
void passer() throw(A) { thrower(); };
void catcher() throw() { try { passer() } catch ( A ) {}; };


while this would not compile
void func() throw() { throw A(); };
void gunc() throw(C,D) { throw A(); };
----
void thrower() throw(A) { throw A(); };
void passer() throw(B) { thrower(); };
void catcher() throw() { passer(); };


thx in advance!
 
R

Ron Natalie

Philipp Holzschneider said:
Are there any available c++ compilers around that strictly
implement the mentioned "Exception Specification"
feature??

Not that I know of. If it would, it would be a violation of the standard. All
an exception specification does is block exceptions from propagating, it
doesn't mean that the code within can't be allowed to throw the disallowed
exceptions.
 
T

tom_usenet

Are there any available c++ compilers around that strictly
implement the mentioned "Exception Specification"
feature??


where the following compiles
void func() { throw A(); };
void gunc() throw(A,B) { throw A(); };
----
void thrower() throw(A) { throw A(); };
void passer() throw(A) { thrower(); };
void catcher() throw() { try { passer() } catch ( A ) {}; };


while this would not compile
void func() throw() { throw A(); };
void gunc() throw(C,D) { throw A(); };

A standard compiler is expected to compile the above code, and call
std::unexpected_exception if an unexpected exception escapes a
function. Some idioms rely on this. Exception specifications are an
entirely runtime feature. They aren't checked at compile time.

Tom
 
K

Kevin Goodsell

tom_usenet said:
A standard compiler is expected to compile the above code, and call
std::unexpected_exception if an unexpected exception escapes a
function. Some idioms rely on this. Exception specifications are an
entirely runtime feature. They aren't checked at compile time.

It calls std::unexpected(), not std::unexpected_exception.

-Kevin
 
P

Philipp Holzschneider

[codesamples]
A standard compiler is expected to compile the above code, and call
std::unexpected_exception if an unexpected exception escapes a
function. Some idioms rely on this. Exception specifications are an
entirely runtime feature. They aren't checked at compile time.

that really sucks :/ i found that out myself recently

why arent exception specifications "compile time type safety for excpt
handling" as it is in (glorious beloved sweet) java? i dont see any reasons
for not beeing able to implement that in future C++ -compilers :(
the only advantage for handling that at runtime would be not to restrict
method invocations by ex-specs, since it is assumed not to throw an
exception anyways (under normal circumstances), so that the application
code isnt forcely filled with exception handling code.

but lotsa "modern" code or should i say, code that i love, uses non
severe exception handling for common controlpaths, and that kinda
codingstyle is perfectly guided by javastyle exceptionspecs and related
features.

phil





PS-OT: anybody out there, who'sp*ssed by oldskool C++ freedom /
doing-by-foot-suffers and wishes to implement some sort of managed C++.Org
language that comes with all the beloved features from java(1.5) while still
retaining C++ stack-located-complex-basictype power (?)
and moreover compiles into java bytecode that is perfectly executed by
every common JRE and compatible to all other java bytecode?????
if so, pm me!!
 
W

WW

Philipp Holzschneider wrote:
[SNIP]
PS-OT: anybody out there, who'sp*ssed by oldskool C++ freedom /
doing-by-foot-suffers and wishes to implement some sort of managed
C++.Org language that comes with all the beloved features from
java(1.5) while still retaining C++ stack-located-complex-basictype
power (?)
and moreover compiles into java bytecode that is perfectly executed by
every common JRE and compatible to all other java bytecode?????
if so, pm me!!

Look at D and all the discussion about it in comp.lang.c++.moderated. If I
understand what you want, you will like it.
 
R

Ron Natalie

Philipp Holzschneider said:
but lotsa "modern" code or should i say, code that i love, uses non
severe exception handling for common controlpaths, and that kinda
codingstyle is perfectly guided by javastyle exceptionspecs and related
features.
Unfortunately by impelementing the "weak" exceptio specifications, any strengthening
of the requirements will break any existing progams that use them at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top