Re: [9fans] compiler double bug.

2009-12-01 Thread erik quanstrom
> seemed to be correct. > but perhaps i misunderstood on second thought, i think i was just getting a delayed fpe. sorry. do you know why the fpe is delayed? so annoying. - erik

Re: [9fans] compiler double bug.

2009-12-01 Thread Charles Forsyth
>the implicit conversion on return also appears botched. both this: uint fun(void) { double g; g = 4215866817.; USED(g); return g; } void main(void) { uint x; double g; x = fun(); USED(x); g = 1.; exits(""); } and

Re: [9fans] compiler double bug.

2009-12-01 Thread erik quanstrom
> so getival returning uint or ulong (or unsigned something-big-enough) avoids > the problem and seems fine to me. good. i always get diff backwards. sorry. i agree on the standard quite. > there is, however, a bug in the compiler elsewhere, in that a suitable (uint) > cast in a > direct assig

Re: [9fans] compiler double bug.

2009-12-01 Thread Charles Forsyth
oh! getival is yours? but it's in the changes on the - lines not the + lines. the diffs have crossed the equator! i think i understand now. so the original had statements such as: wc = (int)getfval(x); and for excessive values in x (that couldn't be represented as an int) there was

Re: [9fans] compiler double bug.

2009-12-01 Thread erik quanstrom
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 >

Re: [9fans] compiler double bug.

2009-12-01 Thread Charles Forsyth
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

Re: [9fans] compiler double bug.

2009-12-01 Thread erik quanstrom
i applied the patch to my fresh port of the one true awk: /n/sources/contrib/quanstro/src/awkupd - erik

Re: [9fans] compiler double bug.

2009-12-01 Thread erik quanstrom
On Tue Dec 1 11:58:47 EST 2009, fors...@terzarima.net wrote: > i hadn't noticed the changed example. > it's removing the cast, which probably isn't right, although > in that particular case it's probably better > that it should trap (because the result is wrong). > what is the actual code in awk t

Re: [9fans] compiler double bug.

2009-12-01 Thread Charles Forsyth
i hadn't noticed the changed example. it's removing the cast, which probably isn't right, although in that particular case it's probably better that it should trap (because the result is wrong). what is the actual code in awk that's equivalent to that sequence?

Re: [9fans] compiler double bug.

2009-12-01 Thread erik quanstrom
alternatively, a sleep will kill the proc since restoring the floating point will trigger the latent trap. - erik

Re: [9fans] compiler double bug.

2009-12-01 Thread erik quanstrom
#include #include void main(void) { int x; double g; g = 4215866817.; x = (uint)g; USED(x); g = 1.; exits(""); }

Re: [9fans] compiler double bug.

2009-12-01 Thread Charles Forsyth
#include #include void main(void) { double g = 4215866817.; print("%d\n", (unsigned int)g); print("%d\n", (unsigned int)g); exits(""); } 8c r.c 8l r.8 ./8.out -79100479 -79100479 no trap. it generates different code. (obviously the %d should be %ud in this case,

Re: [9fans] compiler double bug.

2009-12-01 Thread erik quanstrom
On Tue Dec 1 04:40:09 EST 2009, fors...@terzarima.net wrote: > g = 4215866817.; > x = (int)g; > actually the target variable must be a uint. a cast still traps. is the compiler wrong on this? - erik

Re: [9fans] compiler double bug.

2009-12-01 Thread Charles Forsyth
g = 4215866817.; x = (int)g; does g fit in (int)? (no, (int) is 32 bit signed.) if (int) is (uint) it will fit, and not trap.

Re: [9fans] compiler double bug.

2009-12-01 Thread Charles Forsyth
the fppc points to the offending instruction.

Re: [9fans] compiler double bug.

2009-12-01 Thread erik quanstrom
even more bare-bones version: #include #include void main(void) { int x; double g; g = 4215866817.; x = (int)g; g=1.; USED(x); exits(""); }