Debuggen der SIGFPE-Ausnahme
Posted: 07 Jan 2025, 13:44
Ich arbeite an einem großen Projekt und wir wechseln zu gcc12 und aktualisieren die Boost-Version. In einem der Testfälle sehen wir, wie SIGFPE (Linux) im folgenden Boost-Code eingefügt wird.
Hier ist T long double und Char ist vom Typ char. Jeder Hinweis wird geschätzt.
Hier ist T long double und Char ist vom Typ char. Jeder Hinweis wird geschätzt.
Code: Select all
template
inline static bool add(T& n, Char ch, mpl::true_) // checked add
{
// Ensure n *= Radix will not overflow
T const max = (std::numeric_limits::max)();
T const val = max / Radix;
if (n > val)
return false;
T tmp = n * Radix; //tmp = 0
// Ensure n += digit will not overflow
const int digit = radix_traits::digit(ch); //digit = 4
if (tmp > max - digit) //This line is throwing SIGFPE.
return false;
n = tmp + static_cast(digit);
return true;
}
};