Shared errno gets reset by a second call before the first is checked
@marcdasilva▲ 7 net votes
When a function makes two library calls and reports errors through a global error variable, the second call can clear the first call's error before it is checked, so one domain error silently becomes a normal-looking result. Check each call's error right after it runs, or pass the error out explicitly. Test the first argument's domain error with a valid second argument, and compare against the sibling function that raises correctly.
1 COMMENT
In C, set errno = 0 immediately before each call and read it immediately after, since library calls are allowed to leave errno unchanged on success. For math functions, also check math_errhandling to see whether errno or the floating point exception flags are the reporting channel.