summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
authorPaul Green <Paul.Green@stratus.com>2004-01-15 11:00:15 -0500
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-01-17 22:00:48 +0000
commit8f8d40ab34e002001c7e6f500a987fa1dfb3bd78 (patch)
treeb2032d9a55fde4bc9cf483320b1848bbf6f3005e /pp_pack.c
parentbac662eeb2cdce47175319fe613f5779e780f517 (diff)
downloadperl-8f8d40ab34e002001c7e6f500a987fa1dfb3bd78.tar.gz
Refactor VOS patches for bleadperl and perl-5.8.x
From: "Green, Paul" <Paul.Green@stratus.com> Message-ID: <A2A34F15EE916148BC4C4748223E67A4069FBB15@exna4.stratus.com> p4raw-id: //depot/perl@22171
Diffstat (limited to 'pp_pack.c')
-rw-r--r--pp_pack.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/pp_pack.c b/pp_pack.c
index 3e4993d2e2..834e723bbb 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -2429,11 +2429,17 @@ S_pack_rec(pTHX_ SV *cat, register tempsym_t* symptr, register SV **beglist, SV
given 10**(NV_MAX_10_EXP+1) == 128 ** x solve for x:
x = (NV_MAX_10_EXP+1) * log (10) / log (128)
And with that many bytes only Inf can overflow.
+ Some C compilers are strict about integral constant
+ expressions so we conservatively divide by a slightly
+ smaller integer instead of multiplying by the exact
+ floating-point value.
*/
#ifdef NV_MAX_10_EXP
- char buf[1 + (int)((NV_MAX_10_EXP + 1) * 0.47456)];
+/* char buf[1 + (int)((NV_MAX_10_EXP + 1) * 0.47456)]; -- invalid C */
+ char buf[1 + (int)((NV_MAX_10_EXP + 1) / 2)]; /* valid C */
#else
- char buf[1 + (int)((308 + 1) * 0.47456)];
+/* char buf[1 + (int)((308 + 1) * 0.47456)]; -- invalid C */
+ char buf[1 + (int)((308 + 1) / 2)]; /* valid C */
#endif
char *in = buf + sizeof(buf);