Re: Bug#134822: celestia: Celestia dies with "Floating point exception"
"Marcelo E. Magallon" <mmagallo@debian.org> writes:
> >> Helge Kreutzmann <kreutzm@itp.uni-hannover.de> writes:
>
> > starbrowser.cpp:189: no matching function for call to `min (unsigned int &, size_t)'
>
> Weird. I just fixed celestia to compile with gcc 3.0, which the is
> closest thing I have to the version you have to use (AFAIK). As far as
> I can see, the powerpc autobuilder picked up this just fine, so I'm
> tempted to call a bug on the alpha version of the compiler.
No, it is a bug in the code. std::min is declared as
template <class T> const T& min(const T& a, const T& b);
so the two parameters need to be of the same type. The call looks like
this:
min(nStars, solarSystems->size())
Where nStars is unsigned int and solarSystems-size() is size_t. On 32
bit systems, size_t happens to be identical to unsigned int, so the
bug goes unnoticed. The fix is to declare nStars as size_t, or to
cast one of the parameters.
Falk
Reply to: