473,418 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Compilers that do implement C++ Exception Specifications

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!
--------------------------
Philipp Holzschneider
Rotobee Realtime 3D GmbH
--------------------------

Jul 19 '05 #1
6 2350

"Philipp Holzschneider" <ho***********@rotobee.com> wrote in message news:bl**********@news.eusc.inter.net...
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.
Jul 19 '05 #2
On Wed, 1 Oct 2003 21:24:47 +0200, "Philipp Holzschneider"
<ho***********@rotobee.com> wrote:
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(); };


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
Jul 19 '05 #3
> > [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!!

--------------------------
Philipp Holzschneider
Rotobee Realtime 3D GmbH
--------------------------
Jul 19 '05 #4
tom_usenet wrote:

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
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Jul 19 '05 #5
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.

--
WW aka Attila
Jul 19 '05 #6

"Philipp Holzschneider" <ho***********@rotobee.com> wrote in message news:bl**********@news.eusc.inter.net...

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.
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: linq936 | last post by:
Hi, I have many assert() call in my code, now I am considering to replace them with exception. The reason I want to do this change is that with the program going bigger and bigger, it is hard to...
6
by: benben | last post by:
Why doesn't the following code work? template <typename ExceptionT> void f(void) throw (ExceptionT) { throw ExceptionT(); } Ben
13
by: Derek | last post by:
As I understand it there is a good amount of link compatibility among C compilers. For example, I can compile main.c with GCC and func.c with Sun One and link the objects using either linker (GNU...
1
by: Brian | last post by:
I'm trying to comile some managed C++ code in VC++ 2005 beta that has a lot of exception specifications,ie int func() throw( SomeException*) ; I'm getting these messages: error C2353:...
13
by: junw2000 | last post by:
Is C++ Exception handling useful? think it is too complicated. What kinds of project need to use it? Thanks.
41
by: Stuart Golodetz | last post by:
Hi all, Just wondering whether there's any reason why exception specifications are enforced at runtime, rather than at compile-time like in Java? (This was prompted by reading an article on...
0
by: JosAH | last post by:
Greetings, welcome back at the sequel of the parsers article chapter. This part is dedicated to the ExpressionParser, the largest parser class for our little language. This class parses a...
11
by: George2 | last post by:
Hello everyone, How do you understand the Bjarne's comments about exception specification? Especially, "not required to be checked across compilation-unit" and "violations will not be caught...
12
by: Ioannis Vranos | last post by:
Perhaps a mechanism can be introduced in the C++0x/1x standard, something simple like defining a function as: void somefunc(void) throw() { // ... }
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.