On Tue Dec  1 16:32:33 EST 2009, fors...@terzarima.net wrote:
> those fixes really don't seem right to me. the problem is in getival
> or its callers. somewhere along the way, ULONG_MAX is converted to double
> and then back to int (directly or indirectly). that yields a trap. now, in 
> the case
>       int x;
>       x = (uint)d;
> the compiler is wrong to eliminate the cast, but then again, if x isn't uint
> that's not going to work properly anyway (since x will go negative for big 
> enough values of d).

i don't claim this is the best way to do this!

but getival does elimate the traps.  try it.  it is okay to pass ULONG_MAX
bac as a uint return value, isn't it?  i don't see the compiler doing the
wrong thing in this case.  and ULONG_MAX is an okay uint
value.  (probablly should have used UINT.) 

since there are always numbers (42158668170.) that will trap
even if using uint (or even vlong), i don't see how to avoid doing
the comparison in floating point.

- erik

Reply via email to