Commits

Anonymous committed 03908d4

PR#5761: Incorrect bigarray custom block size

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12964f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

Comments (0)

Files changed (2)

 - PR#5719: ocamlyacc generates code that is not warning 33-compliant
 - PR#5742: missing bound checks in Array.sub
 - PR#5757: GC compaction bug (crash)
+- PR#5761: Incorrect bigarray custom block size
 
 
 OCaml 4.00.0:

otherlibs/bigarray/bigarray_stubs.c

   }
   /* Compute required size in OCaml heap.  Assumes struct caml_ba_array
      is exactly 4 + num_dims words */
+  /* PR#5516: use C99's flexible array types if possible */
+#if (__STDC_VERSION__ >= 199901L)
+  Assert(sizeof(struct caml_ba_array) == 4 * sizeof(value));
+#else
   Assert(sizeof(struct caml_ba_array) == 5 * sizeof(value));
+#endif
   *wsize_32 = (4 + b->num_dims) * 4;
   *wsize_64 = (4 + b->num_dims) * 8;
 }
   case CAML_BA_NATIVE_INT:
     caml_ba_deserialize_longarray(b->data, num_elts); break;
   }
+  /* PR#5516: use C99's flexible array types if possible */
+#if (__STDC_VERSION__ >= 199901L)
+  return sizeof(struct caml_ba_array) + b->num_dims * sizeof(intnat);
+#else
   return sizeof(struct caml_ba_array) + (b->num_dims - 1) * sizeof(intnat);
+#endif
 }
 
 /* Create / update proxy to indicate that b2 is a sub-array of b1 */