https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61628

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #20 from Tobias Burnus <burnus at gcc dot gnu.org> ---
That's a very odd problem. The error message tells us that the size of an array
element (here: 4 byte) does not fit into the SIZE part of the array descriptor.
Obviously, the number "4" (bytes) does fit there.

The questions are:
a) Why does it have the wrong value under Win64 - it should take 4 not some
other value.
b) Why does this message doesn't pop up under Win32 (or Linux)?
c) Why does it fail under Win32?

One thing which looks suspicious is the code for gfc_max_array_element_size; it
should calculate sizeof(ptrdiff_t) - bits used for other purposes. For some
reasons it uses "long" which has no relation to ptrdiff_t and is 32 bytes under
Windows (both 32 and 64 bit Windows). That should be fixed by the following
patch (untested).

However, it still does not explain why it fails with an error message under
Win64 - and only under Win64 and not under Win32. Still, I subspect that the
sizeof(long) == 32 is behind the problems we are seening. Presumably, Cygwin
uses sizeof(long) == 64, which would explain why it only fails with Windows.
(It doesn't explain the other issues.)


[Side remark: I am looking for the new array descriptor to get rid of this
mess. That one has a simple "size_t elem_len", an "int rank" and another
element for the data type.]

--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -956,7 +956,7 @@ gfc_init_types (void)
   n = TYPE_PRECISION (gfc_array_index_type) - GFC_DTYPE_SIZE_SHIFT;
   gfc_max_array_element_size
-    = wide_int_to_tree (long_unsigned_type_node,
+    = wide_int_to_tree (size_type_node,
                        wi::mask (n, UNSIGNED,
-                                 TYPE_PRECISION (long_unsigned_type_node)));
+                                 TYPE_PRECISION (size_type_node)));

   boolean_type_node = gfc_get_logical_type (gfc_default_logical_kind);

Reply via email to