public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] Use correct type for transferring array descriptor  info to library
@ 2007-07-26 14:26 Janne Blomqvist
  2007-07-27  7:21 ` FX Coudert
  0 siblings, 1 reply; 2+ messages in thread
From: Janne Blomqvist @ 2007-07-26 14:26 UTC (permalink / raw)
  To: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 466 bytes --]

Hi,

I plan to commit the following obvious patch in 24 hours unless someone 
objects. The problem is that the array descriptor triplets for each 
dimension (ubound, stride, lbound) are transferred as GFC_INTEGER_4 
rather than as the correct array index type (typedeffed to ssize_t). 
It's a rather obscure bug, surfacing only when doing namelist I/O on big 
arrays on 64-bit platforms. But it's the right thing to do, so it should 
be done.



-- 
Janne Blomqvist

[-- Attachment #2: ChangeLog --]
[-- Type: text/plain, Size: 403 bytes --]

Fortran frontend changelog:

2007-07-26  Janne Blomqvist  <jb@gcc.gnu.org>

	* trans-io.c (gfc_build_io_library_fndecls): Change to use
	gfc_array_index_type for array descriptor triplets instead of
	gfc_int4_type_node.

libgfortran ChangeLog:

2007-07-26  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/transfer.c (st_set_nml_var_dim): Use index_type instead of
	GFC_INTEGER_4 for array descriptor triplets.

[-- Attachment #3: nml-desc.diff --]
[-- Type: text/x-patch, Size: 1812 bytes --]

Index: gcc/fortran/trans-io.c
===================================================================
--- gcc/fortran/trans-io.c	(revision 126947)
+++ gcc/fortran/trans-io.c	(working copy)
@@ -417,8 +417,8 @@ gfc_build_io_library_fndecls (void)
   iocall[IOCALL_SET_NML_VAL_DIM] =
     gfc_build_library_function_decl (get_identifier (PREFIX("st_set_nml_var_dim")),
 				     void_type_node, 5, dt_parm_type,
-				     gfc_int4_type_node, gfc_int4_type_node,
-				     gfc_int4_type_node, gfc_int4_type_node);
+				     gfc_int4_type_node, gfc_array_index_type,
+				     gfc_array_index_type, gfc_array_index_type);
 }
 
 
Index: libgfortran/io/transfer.c
===================================================================
--- libgfortran/io/transfer.c	(revision 126947)
+++ libgfortran/io/transfer.c	(working copy)
@@ -2906,14 +2906,14 @@ st_set_nml_var (st_parameter_dt *dtp, vo
 
 /* Store the dimensional information for the namelist object.  */
 extern void st_set_nml_var_dim (st_parameter_dt *, GFC_INTEGER_4,
-				GFC_INTEGER_4, GFC_INTEGER_4,
-				GFC_INTEGER_4);
+				index_type, index_type,
+				index_type);
 export_proto(st_set_nml_var_dim);
 
 void
 st_set_nml_var_dim (st_parameter_dt *dtp, GFC_INTEGER_4 n_dim,
-		    GFC_INTEGER_4 stride, GFC_INTEGER_4 lbound,
-		    GFC_INTEGER_4 ubound)
+		    index_type stride, index_type lbound,
+		    index_type ubound)
 {
   namelist_info * nml;
   int n;
@@ -2922,9 +2922,9 @@ st_set_nml_var_dim (st_parameter_dt *dtp
 
   for (nml = dtp->u.p.ionml; nml->next; nml = nml->next);
 
-  nml->dim[n].stride = (ssize_t)stride;
-  nml->dim[n].lbound = (ssize_t)lbound;
-  nml->dim[n].ubound = (ssize_t)ubound;
+  nml->dim[n].stride = stride;
+  nml->dim[n].lbound = lbound;
+  nml->dim[n].ubound = ubound;
 }
 
 /* Reverse memcpy - used for byte swapping.  */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, fortran] Use correct type for transferring array descriptor  info to library
  2007-07-26 14:26 [Patch, fortran] Use correct type for transferring array descriptor info to library Janne Blomqvist
@ 2007-07-27  7:21 ` FX Coudert
  0 siblings, 0 replies; 2+ messages in thread
From: FX Coudert @ 2007-07-27  7:21 UTC (permalink / raw)
  To: Janne Blomqvist; +Cc: gfortran, gcc-patches

> I plan to commit the following obvious patch in 24 hours unless  
> someone objects. The problem is that the array descriptor triplets  
> for each dimension (ubound, stride, lbound) are transferred as  
> GFC_INTEGER_4 rather than as the correct array index type  
> (typedeffed to ssize_t). It's a rather obscure bug, surfacing only  
> when doing namelist I/O on big arrays on 64-bit platforms. But it's  
> the right thing to do, so it should be done.

Do you have any ways to write a testcase that doesn't need gigabytes  
of disk space?

The patch is otherwise OK.

FX

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-27  6:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26 14:26 [Patch, fortran] Use correct type for transferring array descriptor info to library Janne Blomqvist
2007-07-27  7:21 ` FX Coudert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).