Topic: exception behaviour of std math functions
Author: 520014not351861-0001@t-online.de (Johannes Reinelt)
Date: Fri, 4 Apr 2003 11:25:30 +0000 (UTC) Raw View
Hi,
what is the specified behaviour for standard c math functions like
pow() regarding error situations? Are they supposed to throw expections?
I don't have the standard document available and the Josuttis book
doesn't clearly tell me.
Thanks
---
[ 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 ]
Author: rmaddox@isicns.com (Randy Maddox)
Date: Sat, 5 Apr 2003 04:20:23 +0000 (UTC) Raw View
520014not351861-0001@t-online.de (Johannes Reinelt) wrote in message news:<b6h6oh$s7c$04$1@news.t-online.com>...
> Hi,
>
> what is the specified behaviour for standard c math functions like
> pow() regarding error situations? Are they supposed to throw expections?
> I don't have the standard document available and the Josuttis book
> doesn't clearly tell me.
>
> Thanks
>
> ---
Since C doesn't have exceptions it would be most surprising if any of
those standard C math functions did throw an exception. :-)
Seriously, the error behavior of those functions is described in the C
standard. In most cases that involves setting errno or returning a
special value.
If you do not have a copy of the relevant standards you may download
them from www.ansi.org for a mere US$18 each for a .pdf version that
can be viewed using AcrobatReader from www.adobe.com. That will
provide you with the definitive answers to your question.
Randy.
---
[ 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 ]
Author: jdennett@acm.org (James Dennett)
Date: Tue, 8 Apr 2003 08:31:50 +0000 (UTC) Raw View
Johannes Reinelt wrote:
> Hi,
>
> what is the specified behaviour for standard c math functions like
> pow() regarding error situations? Are they supposed to throw expections?
> I don't have the standard document available and the Josuttis book
> doesn't clearly tell me.
>
> Thanks
17.4.4.8/2 says "None of the functions from the Standard C library
shall report an error by throwing an exception, unless it calls a
program-supplied function that throws an exception."
(Probably the wording ought to read "No function from the Standard
C library shall report an error by throwing an exception, unless
that function calls a program-supplied function that throws an
exception." I think the meaning is clear enough though that this
doesn't call for a DR.)
It also refers to footnote 176, which says that we can consider
the C library functions as having a throw() exception specification.
-- James.
---
[ 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 ]