The effect of instantiating the template complex for any type other than float, double or long double is unspecified.
If the result of a function is not mathematically defined or not in the range of representable values for its type, the behavior is undefined.