C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

standardizing the exception handling mechanism across platfo
Goto page 1, 2  Next
 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Pavel Kuznetsov
Guest





PostPosted: Thu Aug 11, 2005 3:20 pm    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote



<ravinderthakur (AT) gmail (DOT) com> wrote:

Quote:
however due to the lack of
standardization in the c++ about the way the exceptions are being
handled/propagated, every compiler implements the exceptions handling
in a different way.

It might help if you would be more specific about the aspects of
exception handling which are not specified, and you think they should be.

Quote:
What i am thinking is to standardize the exceptions,if possible, so
that those developing the cross platform applications can use this very
good feature that is exceptions.

Well, exceptions are standardized in a way (please refer to the
chapter 15 of the standard.)

--
Pavel

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
ravinderthakur@gmail.com
Guest





PostPosted: Thu Aug 11, 2005 3:47 pm    Post subject: standardizing the exception handling mechanism across platfo Reply with quote



exception handling is generally advertised as one of the major features
of the languages such as c++. however due to the lack of
standardization in the c++ about the way the exceptions are being
handled/propagated, every compiler implements the exceptions handling
in a different way. As a result people working on the cross platform
solutions hardly use exception handling.

Most of the big softwares that are being developed are cross platform
and since exceptions are implemented in different these softwares
dosn't use exceptions for error recovery.

What i am thinking is to standardize the exceptions,if possible, so
that those developing the cross platform applications can use this very
good feature that is exceptions.


thanks
rt

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]

Back to top
Gene Bushuyev
Guest





PostPosted: Fri Aug 12, 2005 7:10 pm    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote



<ravinderthakur (AT) gmail (DOT) com> wrote

Quote:
exception handling is generally advertised as one of the major features
of the languages such as c++. however due to the lack of
standardization in the c++ about the way the exceptions are being
handled/propagated, every compiler implements the exceptions handling

What exactly do you propose to standardize which is not covered by the
current standard? Compiler may have different implementations of stack
unwinding, exception prologs, etc., which doesn't impact their ability to
comply with the standard.

Quote:
in a different way. As a result people working on the cross platform
solutions hardly use exception handling.

What people? Why? Again, I don't understand what cross-platform problems you
are referring. Our company has products released on around 10 different
paltforms, and we don't have any problems with using exceptions.

- gene

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Nikos Chantziaras
Guest





PostPosted: Sun Aug 14, 2005 12:41 pm    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote

ravinderthakur wrote:
Quote:

exception handling is generally advertised as one of the major
features of the languages such as c++. however due to the lack of
standardization in the c++ about the way the exceptions are being
handled/propagated, every compiler implements the exceptions
handling in a different way.

I don't know who told you this, but it's not true.


Quote:
As a result people working on the cross platform solutions hardly
use exception handling. Most of the big softwares that are being
developed are cross platform and since exceptions are implemented
in different these softwares dosn't use exceptions for error
recovery.

No. When I develop cross platform software, I don't use exception handling
because old compilers don't support it at all (there were C++ compilers even
before there was a C++ standard). The compilers that do support exceptions,
follow the standard, since exception handling *is* standardised.


Quote:
What i am thinking is to standardize the exceptions

This is already the case.


---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
David Abrahams
Guest





PostPosted: Tue Aug 16, 2005 1:32 pm    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote

[email]realnc (AT) hotmail (DOT) com[/email] ("Nikos Chantziaras") writes:

Quote:
ravinderthakur wrote:

exception handling is generally advertised as one of the major
features of the languages such as c++. however due to the lack of
standardization in the c++ about the way the exceptions are being
handled/propagated, every compiler implements the exceptions
handling in a different way.

I don't know who told you this, but it's not true.

Some compilers implement EH in the same way, but it's true as a rule
that given any two compilers, the EH implementation may be different.
Quote:

As a result people working on the cross platform solutions hardly
use exception handling. Most of the big softwares that are being
developed are cross platform and since exceptions are implemented
in different these softwares dosn't use exceptions for error
recovery.

No. When I develop cross platform software, I don't use exception handling
because old compilers don't support it at all (there were C++ compilers even
before there was a C++ standard). The compilers that do support exceptions,
follow the standard, since exception handling *is* standardised.

The *behavior* of exception handling is standardized. In general, the
*binary interface* for exception handling is not standardized, except
on a few platforms that adopted
refspecs.freestandards.org/elf/IA64-SysV-psABI.pdf

It's generally been the position of the C++ committee that ABI
specification/standardization isn't our domain, and it should be left
to those who control the various platforms.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Nikos Chantziaras
Guest





PostPosted: Tue Aug 16, 2005 3:56 pm    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote

David Abrahams wrote:
Quote:
realnc (AT) hotmail (DOT) com ("Nikos Chantziaras") writes:

ravinderthakur wrote:

exception handling is generally advertised as one of the major
features of the languages such as c++. however due to the lack of
standardization in the c++ about the way the exceptions are
being handled/propagated, every compiler implements the
exceptions handling in a different way.

I don't know who told you this, but it's not true.

Some compilers implement EH in the same way, but it's true as a rule
that given any two compilers, the EH implementation may be different.

Yes, the implementation is different. But the usage/semantics of C++ EH
is the same (it's part of the language). That's what the OP was talking
about. He/she wrote:

Quote:
due to the lack of standardization in the c++ about the way the
exceptions are being handled/propagated, every compiler implements
the exceptions handling in a different way.

The standard very well defines how exceptions are handled and propagated.


Quote:
As a result people working on the cross platform solutions hardly
use exception handling. Most of the big softwares that are being
developed are cross platform and since exceptions are
implemented in different these softwares dosn't use exceptions
for error recovery.

No. When I develop cross platform software, I don't use exception
handling because old compilers don't support it at all (there were
C++ compilers even before there was a C++ standard). The compilers
that do support exceptions, follow the standard, since exception
handling *is* standardised.

The *behavior* of exception handling is standardized. In general,
the *binary interface* for exception handling is not standardized,

I wanted to point out that programs can assume that EH works the same on
every compiler that actually supports EH. Binary interfaces are of no
concern to programs.

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
John Nagle
Guest





PostPosted: Tue Aug 16, 2005 7:50 pm    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote

Nikos Chantziaras wrote:

Quote:
David Abrahams wrote:

[email]realnc (AT) hotmail (DOT) com[/email] ("Nikos Chantziaras") writes:

ravinderthakur wrote:

exception handling is generally advertised as one of the major
features of the languages such as c++. however due to the lack of
standardization in the c++ about the way the exceptions are being
handled/propagated, every compiler implements the exceptions
handling in a different way.

I'm not sure what the original poster was really asking for.
But it might be worthwhile to have stronger language suggesting
that all exceptions be derived from class "std::exception".

Misery is catching an exception at "catch ...". All identifying
information has been lost at that point.

But there's a problem with deriving exceptions from
"std::exception".

namespace CEGUI;
class Exception: public std::exception {
..
};

..

try
{
// do CEGUI and std-c++ stuff in here
}
catch (std::exception& exc)
{
// Recover from std usage issue.
}
catch (CEGUI::Exception& exc)
{
// Recover from CEGUI issue
}

..
CEGUI::Exception foo;
throw foo;

Which "catch" gets that exception? The less restrictive
clause is first, and std::exception will match, so it
looks like CEGUI::Exception will never be matched, and
is thus unreachable.

Here's a project that hit that problem, and decided not to use
std::exception because of it.

http://www.cegui.org.uk/modules/newbb/viewtopic.php?topic_id=900&post_id=5220

This is perhaps the only place in C++ where order of statements affects
type matching. Should it work that way? Should unreachable catch
clauses like that be an error? They're clearly detectable at
compile time.

John Nagle
Animats

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Shezan Baig
Guest





PostPosted: Wed Aug 17, 2005 3:10 am    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote

John Nagle wrote:
Quote:
This is perhaps the only place in C++ where order of statements affects
type matching. Should it work that way? Should unreachable catch
clauses like that be an error? They're clearly detectable at
compile time.


How about "catch block overload resolution" that behaves the same way
as function overload resolution?

-shez-

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
ThosRTanner
Guest





PostPosted: Wed Aug 17, 2005 2:52 pm    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote


"Pavel Kuznetsov" wrote:
Quote:
ravinderthakur (AT) gmail (DOT) com> wrote:

however due to the lack of
standardization in the c++ about the way the exceptions are being
handled/propagated, every compiler implements the exceptions handling
in a different way.

It might help if you would be more specific about the aspects of
exception handling which are not specified, and you think they should be.

What i am thinking is to standardize the exceptions,if possible, so
that those developing the cross platform applications can use this very
good feature that is exceptions.

Well, exceptions are standardized in a way (please refer to the
chapter 15 of the standard.)
Is it possible he is referring to the issue where certain systems use

the C++ exception handling mechanism to deal with OS or hardware
errors. This creates absolute havoc, because the behaviour of:

int wibble(int *a) throw()
{
return *a;
}

int fred = wibble(0)

is going to be strangely different on different platforms (I know, it's
the coders fault for writing code like that - but presumably there may
be other reasons why the O/S might decide to deal with some wacky error
by throwing an exception?)

Certainly this behaviour is enough to generate a few questions /
answers in various C++ FAQs.

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Stephan Bergmann
Guest





PostPosted: Thu Aug 18, 2005 5:33 am    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote

Shezan Baig wrote:
Quote:
John Nagle wrote:

This is perhaps the only place in C++ where order of statements affects
type matching. Should it work that way? Should unreachable catch
clauses like that be an error? They're clearly detectable at
compile time.



How about "catch block overload resolution" that behaves the same way
as function overload resolution?

struct A {};
struct B {};
void f() throws (A, B);

try { f(); }
catch (A &) { ... }
catch (B &) { ... }

would work fine, but as soon as someone adds

struct C: public A, public B {};

and modifies the implementation of f to throw an instance of C, what
should happen?

-Stephan

Quote:
-shez-

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Bob Bell
Guest





PostPosted: Thu Aug 18, 2005 5:40 am    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote

John Nagle wrote:
Quote:
Nikos Chantziaras wrote:

David Abrahams wrote:

[email]realnc (AT) hotmail (DOT) com[/email] ("Nikos Chantziaras") writes:

ravinderthakur wrote:

exception handling is generally advertised as one of the major
features of the languages such as c++. however due to the lack of
standardization in the c++ about the way the exceptions are being
handled/propagated, every compiler implements the exceptions
handling in a different way.

I'm not sure what the original poster was really asking for.
But it might be worthwhile to have stronger language suggesting
that all exceptions be derived from class "std::exception".

Misery is catching an exception at "catch ...". All identifying
information has been lost at that point.

Not true; you can rethrow and catch to recover the exception type.

Quote:
But there's a problem with deriving exceptions from
"std::exception".

There are lots of problems with mandating that all exceptions be
derived from std::exception, among them the fact that tons of code
would break.

Bob

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Steven T. Hatton
Guest





PostPosted: Fri Aug 19, 2005 4:58 am    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote

Bob Bell wrote:

Quote:
John Nagle wrote:
I'm not sure what the original poster was really asking for.
But it might be worthwhile to have stronger language suggesting
that all exceptions be derived from class "std::exception".

Misery is catching an exception at "catch ...". All identifying
information has been lost at that point.

Not true; you can rethrow and catch to recover the exception type.

If it's polymorphic, or otherwise selfdescriptive. I don't believe there is
any way to extract type information from fundamental types at runtime.

Quote:
But there's a problem with deriving exceptions from
"std::exception".

There are lots of problems with mandating that all exceptions be
derived from std::exception, among them the fact that tons of code
would break.

Bob

Mandating that they _must_ is not the same as strongly suggesting
they /should/ derive from std::exception. Exception handling should be an
aid to the programmer, not an additional challenge.

My opinion is that the default behavior of the exception handling mechanism
in C++ should produce a message describing as completely as possible any
exception which unwound the stack to to point of popping main(). It would
also be a good idea, if technically feasible, to require all exceptions to
derive from std::exception by default, and provide a mechanism to override
that restriction in order to support legacy, and esoteric code.
--


Back to top
John Nagle
Guest





PostPosted: Fri Aug 19, 2005 4:58 am    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote

Stephan Bergmann wrote:
Quote:
Shezan Baig wrote:

John Nagle wrote:

This is perhaps the only place in C++ where order of statements affects
type matching. Should it work that way? Should unreachable catch
clauses like that be an error? They're clearly detectable at
compile time.




How about "catch block overload resolution" that behaves the same way
as function overload resolution?


struct A {};
struct B {};
void f() throws (A, B);

try { f(); }
catch (A &) { ... }
catch (B &) { ... }

would work fine, but as soon as someone adds

struct C: public A, public B {};

and modifies the implementation of f to throw an instance of C, what
should happen?

Yes, we hit that because exception specifications aren't taken
seriously.

Something similar to that happens when you write

struct A ();
struct B ();
struct C: public a, public B();

void f(A&);
void f(B&);

C cinstance;

f(cinstance); // ambiguous

Same ambiguity. But because function definitions are
taken seriously, that's considered an error.

Another "too late to fix" problem.

C++ has too many legacy problems like this.

John Nagle

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Shezan Baig
Guest





PostPosted: Fri Aug 19, 2005 3:42 pm    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote

John Nagle wrote:
Quote:
Yes, we hit that because exception specifications aren't taken
seriously.

Something similar to that happens when you write

struct A ();
struct B ();
struct C: public a, public B();

void f(A&);
void f(B&);

C cinstance;

f(cinstance); // ambiguous

Same ambiguity. But because function definitions are
taken seriously, that's considered an error.


Actually, there is a difference in this case. Because the type of the
argument is known at compile time, that is why it is easy to consider
it an error. However, in Stephan's example, the type of exception can
only be known at runtime, which makes it impossible to give a
compile-time error. Unless we take the Java approach where all
exceptions need to be declared explicitly in the funtion signature -
but that seems to me like a bigger pain than its worth - I would much
rather it select the first possible match for handling the exception.

-shez-

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
kuyper@wizard.net
Guest





PostPosted: Fri Aug 19, 2005 3:42 pm    Post subject: Re: standardizing the exception handling mechanism across pl Reply with quote

"Steven T. Hatton" wrote:
Quote:
Bob Bell wrote:

John Nagle wrote:
..
Misery is catching an exception at "catch ...". All identifying
information has been lost at that point.

Not true; you can rethrow and catch to recover the exception type.

If it's polymorphic, or otherwise selfdescriptive. I don't believe there is
any way to extract type information from fundamental types at runtime.

When the exception is rethrown, it can be caught just as easily whether
it's a fundamental type or a polymorphic type; all that's needed is a
catch statement that actually specifies the type. The type information
isn't lost.

..
Quote:
My opinion is that the default behavior of the exception handling mechanism
in C++ should produce a message describing as completely as possible any
exception which unwound the stack to to point of popping main(). It would
also be a good idea, if technically feasible, to require all exceptions to
derive from std::exception by default, and provide a mechanism to override
that restriction in order to support legacy, and esoteric code.

Your not supporting legacy code unless the new default behavior is the
same as the old behavior. If you provide some mechanism for invoking
the old behavior, then either old code or old build scripts/make files
have to be modified. That doesn't qualify as supporting legacy code.

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.