Bug 6781

Summary: sin() does not set errno on domain error
Product: glibc Reporter: Michael Kerrisk <mtk.manpages>
Component: mathAssignee: Andreas Jaeger <aj>
Status: RESOLVED FIXED    
Severity: normal CC: glibc-bugs
Priority: P2 Flags: fweimer: security-
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Attachments: test program

Description Michael Kerrisk 2008-07-30 11:44:44 UTC
For a domain error, sin() does not set errno.  It should set errno to EDOM.

NOTE: the inverse trig functions do correctly set errno on error!

Background: 
On error, many glibc math functions both set errno and raise an exception
(fetestexcept(3)).  For example, the following  function all do this: acos(),
asin(), cosh(), sinh(), acosh(), asinh(), exp(), exp2(), ldexp(), log(),
log10(), log2().  However, there is much inconsistency.  Some functions raise an
exception, but don't set errno.  Some functions set errno for some errors, but
not others.  A few set errno, but don't raise an exception.  This series of bug
reports documents deviations from what I consider the ideal: all functions
should BOTH set errno AND raise an exception for all errors.

All of these reports relate to tests on glibc 2.8 (as provided by SUSE 11.0).
Comment 1 Michael Kerrisk 2008-07-31 08:38:09 UTC
Created attachment 2846 [details]
test program

sample run showing problem:

$ /tmp/mt_sin inf
errno == 0
fetestexcept() says:  FE_INVALID
sin(inf)=nan
0 FE_INVALID nan
Comment 2 Michael Kerrisk 2010-09-11 15:09:36 UTC
This bug was fixed in glibc 2.10. The man page is updated for man-pages-2.37.