summaryrefslogtreecommitdiff
path: root/src/cmd/ld
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-11-15 12:57:09 -0800
committerRuss Cox <rsc@golang.org>2009-11-15 12:57:09 -0800
commita58fd66357f6b2b1cf1b50d0f93eb30fd28d7693 (patch)
tree4df91b85cdb8c5bfe3bb1ac5be58df0e5ecd375d /src/cmd/ld
parent9c40101b22b381b3946e373a6d50000d348146f5 (diff)
downloadgolang-a58fd66357f6b2b1cf1b50d0f93eb30fd28d7693.tar.gz
gc: five bug fixes, one better error.
* check for struct literal assignment to private fields. * record, fix crash involving parallel map assignment. * avoid infinite recursion in exportassignok. * make floating point bounds check precise. * avoid crash on invalid receiver. * add context to error about implicit assignment. Fixes issue 86. Fixes issue 88. Fixes issue 158. Fixes issue 174. Fixes issue 201. Fixes issue 204. R=ken2 http://codereview.appspot.com/154144
Diffstat (limited to 'src/cmd/ld')
-rw-r--r--src/cmd/ld/lib.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c
index 4a518c79b..232916845 100644
--- a/src/cmd/ld/lib.c
+++ b/src/cmd/ld/lib.c
@@ -599,8 +599,13 @@ ieeedtof(Ieee *e)
exp++;
}
}
- if(exp <= -126 || exp >= 130)
- diag("double fp to single fp overflow");
+ if(-148 <= exp && exp <= -126) {
+ v |= 1<<23;
+ v >>= -125 - exp;
+ exp = -126;
+ }
+ else if(exp < -148 || exp >= 130)
+ diag("double fp to single fp overflow: %.17g", ieeedtod(e));
v |= ((exp + 126) & 0xffL) << 23;
v |= e->h & 0x80000000L;
return v;
@@ -620,14 +625,18 @@ ieeedtod(Ieee *ieeep)
}
if(ieeep->l == 0 && ieeep->h == 0)
return 0;
+ exp = (ieeep->h>>20) & ((1L<<11)-1L);
+ exp -= (1L<<10) - 2L;
fr = ieeep->l & ((1L<<16)-1L);
fr /= 1L<<16;
fr += (ieeep->l>>16) & ((1L<<16)-1L);
fr /= 1L<<16;
- fr += (ieeep->h & (1L<<20)-1L) | (1L<<20);
+ if(exp == -(1L<<10) - 2L) {
+ fr += (ieeep->h & (1L<<20)-1L);
+ exp++;
+ } else
+ fr += (ieeep->h & (1L<<20)-1L) | (1L<<20);
fr /= 1L<<21;
- exp = (ieeep->h>>20) & ((1L<<11)-1L);
- exp -= (1L<<10) - 2L;
return ldexp(fr, exp);
}