summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
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);