why does unhandled domain_error from sqrt() not cause a terminate?

Hi,

I have a question:
why does unhandled domain_error from sqrt() not cause a terminate?

for a example:
1
2
3
4
void main(){
   std::sqrt(-2); // Will not cause terminate()
   throw std::domain_error(); // Will cause terminate()
}

cheers
qon
Last edited on
Usually functions from cmath don't throw exceptions
Ok,
from http://www.cplusplus.com/reference/clibrary/cmath/sqrt/ :
If the argument is negative, a domain error occurs, setting the global variable errno to the value EDOM

I assumed this meant that a domain_error exception was thrown.
Topic archived. No new replies allowed.