diff -u -r otherlibs/bigarray/bigarray.h /var/tmp/ocaml/trunk/otherlibs/bigarray/bigarray.h
--- otherlibs/bigarray/bigarray.h	2008-12-03 19:09:09.000000000 +0100
+++ /var/tmp/ocaml/trunk/otherlibs/bigarray/bigarray.h	2012-03-06 11:37:25.000000000 +0100
@@ -73,7 +73,12 @@
   intnat num_dims;            /* Number of dimensions */
   intnat flags;  /* Kind of element array + memory layout + allocation status */
   struct caml_ba_proxy * proxy; /* The proxy for sub-arrays, or NULL */
+  /* PR#5516: use C99's / gcc's flexible array types if possible */
+#if (__STDC_VERSION__ >= 199901L)
+  intnat dim[]  /*[num_dims]*/; /* Size in each dimension */
+#else
   intnat dim[1] /*[num_dims]*/; /* Size in each dimension */
+#endif
 };
 
 #define Caml_ba_array_val(v) ((struct caml_ba_array *) Data_custom_val(v))
diff -u -r otherlibs/bigarray/bigarray_stubs.c /var/tmp/ocaml/trunk/otherlibs/bigarray/bigarray_stubs.c
--- otherlibs/bigarray/bigarray_stubs.c	2011-05-12 16:34:05.000000000 +0200
+++ /var/tmp/ocaml/trunk/otherlibs/bigarray/bigarray_stubs.c	2012-03-06 11:37:25.000000000 +0100
@@ -121,20 +123,20 @@
 
 /* Allocation of a big array */
 
-#define CAML_BA_MAX_MEMORY 256*1024*1024
-/* 256 Mb -- after allocating that much, it's probably worth speeding
+#define CAML_BA_MAX_MEMORY 1024*1024*1024
+/* 1 Gb -- after allocating that much, it's probably worth speeding
    up the major GC */
 
 /* [caml_ba_alloc] will allocate a new bigarray object in the heap.
    If [data] is NULL, the memory for the contents is also allocated
    (with [malloc]) by [caml_ba_alloc].
-   [data] cannot point into the Caml heap.
-   [dim] may point into an object in the Caml heap.
+   [data] cannot point into the OCaml heap.
+   [dim] may point into an object in the OCaml heap.
 */
 CAMLexport value
 caml_ba_alloc(int flags, int num_dims, void * data, intnat * dim)
 {
-  uintnat num_elts, size;
+  uintnat num_elts, asize, size;
   int overflow, i;
   value res;
   struct caml_ba_array * b;
@@ -158,10 +160,13 @@
     if (data == NULL && size != 0) caml_raise_out_of_memory();
     flags |= CAML_BA_MANAGED;
   }
-  res = caml_alloc_custom(&caml_ba_ops,
-                          sizeof(struct caml_ba_array)
-                          + (num_dims - 1) * sizeof(intnat),
-                          size, CAML_BA_MAX_MEMORY);
+  /* PR#5516: use C99's / gcc's flexible array types if possible */
+#if (__STDC_VERSION__ >= 199901L)
+  asize = sizeof(struct caml_ba_array) + num_dims * sizeof(intnat);
+#else
+  asize = sizeof(struct caml_ba_array) + (num_dims - 1) * sizeof(intnat);
+#endif
+  res = caml_alloc_custom(&caml_ba_ops, asize, size, CAML_BA_MAX_MEMORY);
   b = Caml_ba_array_val(res);
   b->data = data;
   b->num_dims = num_dims;
@@ -181,6 +186,7 @@
   int i;
   value res;
 
+  Assert(num_dims <= CAML_BA_MAX_NUM_DIMS);
   va_start(ap, data);
   for (i = 0; i < num_dims; i++) dim[i] = va_arg(ap, intnat);
   va_end(ap);
@@ -1062,7 +1084,7 @@
   num_elts = 1;
   for (i = 0; i < num_dims; i++) {
     dim[i] = Long_val(Field(vdim, i));
-    if (dim[i] < 0 || dim[i] > 0x7FFFFFFFL)
+    if (dim[i] < 0)
       caml_invalid_argument("Bigarray.reshape: negative dimension");
     num_elts *= dim[i];
   }
