This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran] Fix PR19194 : type mismatch between library and compiler


PR 19194 is a type mismatch on platforms where pointers are wider than
integers.  This lead the REC and RECL parameters to fail on (some) 64bit
platforms.

The patch to trans-io.c fixes those issues which were obviously due to typos.
  I vaguely remember that there are platforms where int is 64 bit wide, which
would also break, because while the compiler uses integer*4, the library uses
int.  In order to fix those I changed the library to consistently use
GFC_INTEGER_4 instead of int.  (Note that there are dependency issues in
lbgfortran, PR 19273, so the changed to io.h might not be picked up in the
build.  This doesn't introduce any inconsistencies, it might only prevent this
patch from curing these issues in non-clean builds on platforms which are
currently broken.)  The patch to io.h also slightly cleans up the definition
of struct st_parameter, to make it easier to spot errors of this kind.

Bubblestrapped and regtested on i686-pc-linux, John David Anglin comfirmed
that this fixes all similar errors on hppa64-hp-hpux11.11, but I've not yet
received confirmation that it also works on mips-sgi-irix6.5.

OK?

- Tobi

2005-01-06  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>

gcc/fortran/
	PR fortran/19194
	* trans-io.h: Update copyright years.
	(gfc_build_io_library_fndecls): 'rec' and 'recl_in' are not pointer
	fields.

libgfortran/
	PR fortran/19194
	* io/io.h: Update copyright years.
	(st_parameter): Use 'GFC_INTEGER_4' instead of 'int', use CHARACTER
	macro for definition of string valued paramters.

Index: trans-io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-io.c,v
retrieving revision 1.25
diff -u -p -r1.25 trans-io.c
--- trans-io.c  3 Jan 2005 21:43:55 -0000       1.25
+++ trans-io.c  6 Jan 2005 00:14:10 -0000
@@ -1,5 +1,5 @@
 /* IO Code translation/library interface
-   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    Contributed by Paul Brook

 This file is part of GCC.
@@ -181,11 +181,11 @@ gfc_build_io_library_fndecls (void)
   ADD_FIELD (opened, gfc_pint4_type_node);
   ADD_FIELD (number, gfc_pint4_type_node);
   ADD_FIELD (named, gfc_pint4_type_node);
-  ADD_FIELD (rec, gfc_pint4_type_node);
+  ADD_FIELD (rec, gfc_int4_type_node);
   ADD_FIELD (nextrec, gfc_pint4_type_node);
   ADD_FIELD (size, gfc_pint4_type_node);

-  ADD_FIELD (recl_in, gfc_pint4_type_node);
+  ADD_FIELD (recl_in, gfc_int4_type_node);
   ADD_FIELD (recl_out, gfc_pint4_type_node);

   ADD_FIELD (iolength, gfc_pint4_type_node);

Index: io.h
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/io.h,v
retrieving revision 1.13
diff -u -p -r1.13 io.h
--- io.h        12 Dec 2004 08:59:04 -0000      1.13
+++ io.h        6 Jan 2005 13:29:31 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    Contributed by Andy Vaught

 This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -158,8 +158,8 @@ unit_mode;

 typedef struct
 {
-  int unit;
-  int err, end, eor, list_format;      /* These are flags, not values.  */
+  GFC_INTEGER_4 unit;
+  GFC_INTEGER_4 err, end, eor, list_format; /* These are flags, not values.  */

 /* Return values from library statements.  These are returned only if
    the labels are specified in the statement itself and the condition
@@ -176,58 +176,44 @@ typedef struct
   }
   library_return;

-  int *iostat, *exist, *opened, *number, *named, rec, *nextrec, *size;
-
-  int recl_in;
-  int *recl_out;
-
-  int *iolength;
-
-  char *file;
-  int file_len;
-  char *status;
-  int status_len;
-  char *access;
-  int access_len;
-  char *form;
-  int form_len;
-  char *blank;
-  int blank_len;
-  char *position;
-  int position_len;
-  char *action;
-  int action_len;
-  char *delim;
-  int delim_len;
-  char *pad;
-  int pad_len;
-  char *format;
-  int format_len;
-  char *advance;
-  int advance_len;
-  char *name;
-  int name_len;
-  char *internal_unit;
-  int internal_unit_len;
-  char *sequential;
-  int sequential_len;
-  char *direct;
-  int direct_len;
-  char *formatted;
-  int formatted_len;
-  char *unformatted;
-  int unformatted_len;
-  char *read;
-  int read_len;
-  char *write;
-  int write_len;
-  char *readwrite;
-  int readwrite_len;
+  GFC_INTEGER_4 *iostat, *exist, *opened, *number, *named;
+  GFC_INTEGER_4 rec;
+  GFC_INTEGER_4 *nextrec, *size;
+
+  GFC_INTEGER_4 recl_in;
+  GFC_INTEGER_4 *recl_out;
+
+  GFC_INTEGER_4 *iolength;
+
+#define CHARACTER(name) \
+              char * name; \
+              GFC_INTEGER_4 name ## _len
+  CHARACTER (file);
+  CHARACTER (status);
+  CHARACTER (access);
+  CHARACTER (form);
+  CHARACTER (blank);
+  CHARACTER (position);
+  CHARACTER (action);
+  CHARACTER (delim);
+  CHARACTER (pad);
+  CHARACTER (format);
+  CHARACTER (advance);
+  CHARACTER (name);
+  CHARACTER (internal_unit);
+  CHARACTER (sequential);
+  CHARACTER (direct);
+  CHARACTER (formatted);
+  CHARACTER (unformatted);
+  CHARACTER (read);
+  CHARACTER (write);
+  CHARACTER (readwrite);

 /* namelist related data */
-  char * namelist_name;
-  int namelist_name_len;
+  CHARACTER (namelist_name);
   int namelist_read_mode;
+
+#undef CHARACTER
 }
 st_parameter;



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]