Comments on unpack 'D' and long doubles formats.
authorJarkko Hietaniemi <jhi@iki.fi>
Sun, 21 Sep 2014 20:17:06 +0000 (16:17 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Sun, 21 Sep 2014 20:20:25 +0000 (16:20 -0400)
pp_pack.c

index d35a5af..dbbf2e9 100644 (file)
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -1698,6 +1698,18 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
                ld_bytes aldouble;
                 SHIFT_BYTES(utf8, s, strend, aldouble.bytes,
                             sizeof(aldouble.bytes), datumtype, needs_swap);
+                /* The most common long double format, the x86 80-bit
+                 * extended precision, has either 2 or 6 unused bytes,
+                 * which may contain garbage, which may contain
+                 * unintentional data.  While we do zero the bytes of
+                 * the long double data in pack(), here in unpack() we
+                 * don't, because it's really hard to envision that
+                 * reading the long double off aldouble would be
+                 * affected the unused bytes.
+                 *
+                 * Note that trying to unpack 'long doubles' of 'long
+                 * doubles' packed in another system is in the general
+                 * case doomed without having more detail. */
                if (!checksum)
                    mPUSHn(aldouble.ld);
                else