In Stroustrup he talks of a MathErr class that you can use to catch
floating point exceptions.
It doesn't exist, at least not in Visual C++
I can catch FP exceptions using catch(...) but am stumped in finding
out what the class I'm catching is.
I would like to know how to catch them in a more elegant way than
catch(...) and then poling around in registers to guess the problem.
TIA
EoG
Mar 18 '07
12 1794
On 19 Mar, 19:10, EvilOld...@goog lemail.com wrote:
I'm trying to do diagnositcs on broken floating point code, hence I
don't care about speed, but care a lot about it not dying.
Erik has recaptured my point that I've reached. I can catch FP
exceptions, but can't work out their class and am forced to use
catch(...)
I'm doing it in (spite of) VC++ but I came to this thread because I
was hoping that standard C++ might have a standard way of handing FP
exceptions.
If this isn't part of the C++ standard, why not ?
Nope, not as exceptions at least. It looks like you can determine the
type of FP exception (at least to some degree) using SEH.
I accept that at the lower level it's processor and O/S dependant, but
isn't the point of a standardised high(ish) language that I can write
platform independant code ?
If you want true platform independence you can only standardize the
common subset of all platforms, so if not all platforms support a
certain action then you can not include it unless it can be emulated.
I would suspect that FP exceptions were one of those things that were
not supported on all platforms.
Another problem with FP exceptions is that they are often asynchronous
in the sense that due to optimizations and other stuff you have
already started to execute one or more other statements when the
exception arises. What if you are executing two FP ops and one of them
raises an exception, how to tell which caused the exception, remember
that they can also have been rearranged by the CPU before execution.
--
Erik Wikström
On 20 Mar, 07:52, "Erik Wikström" <eri...@student .chalmers.sewro te:
On 19 Mar, 19:10, EvilOld...@goog lemail.com wrote:
I'm trying to do diagnositcs on broken floating point code, hence I
don't care about speed, but care a lot about it not dying.
Erik has recaptured my point that I've reached. I can catch FP
exceptions, but can't work out their class and am forced to use
catch(...)
I'm doing it in (spite of) VC++ but I came to this thread because I
was hoping that standard C++ might have a standard way of handing FP
exceptions.
If this isn't part of the C++ standard, why not ?
Nope, not as exceptions at least. It looks like you can determine the
type of FP exception (at least to some degree) using SEH.
I accept that at the lower level it's processor and O/S dependant, but
isn't the point of a standardised high(ish) language that I can write
platform independant code ?
If you want true platform independence you can only standardize the
common subset of all platforms, so if not all platforms support a
certain action then you can not include it unless it can be emulated.
I would suspect that FP exceptions were one of those things that were
not supported on all platforms.
Another problem with FP exceptions is that they are often asynchronous
in the sense that due to optimizations and other stuff you have
already started to execute one or more other statements when the
exception arises. What if you are executing two FP ops and one of them
raises an exception, how to tell which caused the exception, remember
that they can also have been rearranged by the CPU before execution.
--
Erik Wikström
Although FP exceptions are asychronous, is it not the case that
processors have the equivalent of the Intel fwait, which synchronises
them ?
On 20 Mar, 09:43, "dominic.con... @gmail.com"
<dominic.con... @gmail.comwrote :
On 20 Mar, 07:52, "Erik Wikström" <eri...@student .chalmers.sewro te:
On 19 Mar, 19:10, EvilOld...@goog lemail.com wrote:
I'm trying to do diagnositcs on broken floating point code, hence I
don't care about speed, but care a lot about it not dying.
Erik has recaptured my point that I've reached. I can catch FP
exceptions, but can't work out their class and am forced to use
catch(...)
I'm doing it in (spite of) VC++ but I came to this thread because I
was hoping that standard C++ might have a standard way of handing FP
exceptions.
If this isn't part of the C++ standard, why not ?
Nope, not as exceptions at least. It looks like you can determine the
type of FP exception (at least to some degree) using SEH.
I accept that at the lower level it's processor and O/S dependant, but
isn't the point of a standardised high(ish) language that I can write
platform independant code ?
If you want true platform independence you can only standardize the
common subset of all platforms, so if not all platforms support a
certain action then you can not include it unless it can be emulated.
I would suspect that FP exceptions were one of those things that were
not supported on all platforms.
Another problem with FP exceptions is that they are often asynchronous
in the sense that due to optimizations and other stuff you have
already started to execute one or more other statements when the
exception arises. What if you are executing two FP ops and one of them
raises an exception, how to tell which caused the exception, remember
that they can also have been rearranged by the CPU before execution.
--
Erik Wikström
Although FP exceptions are asychronous, is it not the case that
processors have the equivalent of the Intel fwait, which synchronises
them ?
Don't know, but I bet that some processors for embedded systems don't.
--
Erik Wikström This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Mertz |
last post by:
At the suggestion of one of my correspondents, I slightly reluctantly
implemented an RSS feed for my website/writing. It is perhaps a bit
crude so far, but maybe I'll spiff it up. The RSS also has an HTML
front to it.
If you want to see the latest news about my _Charming Python_ or _XML
Matters_ columns, or about other articles (later, perhaps stuff about
my book), take a look at:
http://gnosis.cx/rss.xml
|
by: Steven T. Hatton |
last post by:
I read Stroustrup's article of the day:
http://www.research.att.com/~bs/C++.html
Programming with Exceptions. InformIt.com. April 2001.
http://www.research.att.com/~bs/eh_brief.pdf
Some of these ideas are finally beginning to sink in. I believe I looked at
the same article a while back and decided I wasn't quite ready for it. If I
understood things correctly, there seems to be a slight problem with the
design of his exception safe...
|
by: Aguilar, James |
last post by:
Hello all,
To begin, yes, this -is- a homework assignment. However, it is for my
Algorithms class, and my instructor has given us explicit permission to use
"expert" groups like newsgroups, so if that's your only reason not to help,
please do. Otherwise, I guess it's OK. But, just remember, I'm not asking
you to do my work for me, just to point out my error.
My problem is not with the algorithm itself (standard divide and conquer on...
|
by: dinks |
last post by:
Hi,
I'm new to C++ and have been assigned a task which i dont completely
understand. Any help would be greately appreciated.
Here is the problem:
The class "linkedListType" use the "assert" facility. I am to get rid
of them and replace them with exceptions. I need to create a
"linkedListException" class that's declared and implemented in my
"linkedListType" class. This class needs to inherit from the base
"exception" class and return...
|
by: juergen perlinger |
last post by:
Hello out there.
sometimes I need to have proper control of the floating point arithmetic of
the C(and C++) runtime system, and using the f.p. exception handling of the
C99 standard is quite handy for that purpose. The only problem when dealing
with f.p. exception signals is that there is (afaik) no specification *when*
the f.p. exception is raised, with one notable exception:
'feraiseexcept(int)' raises the exceptions passed in the...
| |
by: Lasse Edsvik |
last post by:
Hello
I'm trying to build a simple COM+ app in vs.net using C# and i cant register
it in component manager.....
what more is needed than this:
using System;
using System.EnterpriseServices;
|
by: Jason Huang |
last post by:
Hi,
Would someone explain the following coding more detail for me? What's the
( ) for?
CurrentText = (TextBox)e.Item.Cells.Controls;
Thanks.
Jason
|
by: Deepak C.G via .NET 247 |
last post by:
I want to dispose the image object in my child form, unless I won't dispose this
object i can't delete the image file in my folder.
I get this error in MDIparent form
"An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll"
"Additional information: Invalid parameter used."
Here is my code:-
|
by: vainstah |
last post by:
Hello Guys and Galls,
To start off, I have reached the solution I was looking for, but I would like comments and feedback on the solution I have reached and tips/tricks on making it more elegant. I am not satisfied with the underlying machinery of the solution though.
I am an advanced C programmer and most do object-based programming in C++. Please do not reply to this article with references to basic material or obvious tips.
An...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |