Closed
Description
Hi there,
I've come across some undefined behaviour in calculate_Tin_from_qin
. Depending on the compiler and compilation options, when the sqrt
argument is negative the following will either yield a NaN
or Tmltk
. Replacing min
with ieee_min_num
fixes this for my use case, and will consistently return Tmltk
when the sqrt
argument is negative, independent of the compiler.
Tin = min((-bb1 - sqrt(bb1*bb1 - c4*aa1*cc1)) / &
(c2*aa1),Tmltk)
Happy to submit a PR from my fork https://github.com/kieranricardo/Icepack/tree/bugfix-calculate_Tin_from_qin-undefined-behaviour :)