]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libfortran/39665 (Fortran IO using unaligned accesses to read/write doubles.)
authorJanne Blomqvist <jb@gcc.gnu.org>
Thu, 9 Apr 2009 17:44:23 +0000 (20:44 +0300)
committerJanne Blomqvist <jb@gcc.gnu.org>
Thu, 9 Apr 2009 17:44:23 +0000 (20:44 +0300)
2009-04-09  Janne Blomqvist  <jb@gcc.gnu.org>

PR fortran/39665
* io/io.h (st_parameter_dt): Add aligned attribute to u.p.value.
* io/read.c (convert_real): Add note about alignment requirements.

From-SVN: r145852

libgfortran/ChangeLog
libgfortran/io/io.h
libgfortran/io/read.c

index d9a2d6cd63d7187882d5abe9974e94826212acd0..f14cf603bb626107fad168722f21fab1f57a4cf8 100644 (file)
@@ -1,3 +1,9 @@
+2009-04-09  Janne Blomqvist  <jb@gcc.gnu.org>
+
+       PR libfortran/39665
+       * io/io.h (st_parameter_dt): Add aligned attribute to u.p.value.
+       * io/read.c (convert_real): Add note about alignment requirements.
+
 2009-04-09  Nick Clifton  <nickc@redhat.com>
 
        * m4/cshift0.m4: Change copyright header to refer to version 3
index 02b14ce4a0f80b74214ab3e1060b33738da8091a..5ee0979c1e8838f1c02767ad60f9fbb6d94e3a3a 100644 (file)
@@ -498,10 +498,11 @@ typedef struct st_parameter_dt
          /* A flag used to identify when a non-standard expanded namelist read
             has occurred.  */
          int expanded_read;
-         /* Storage area for values except for strings.  Must be large
-            enough to hold a complex value (two reals) of the largest
-            kind.  */
-         char value[32];
+         /* Storage area for values except for strings.  Must be
+            large enough to hold a complex value (two reals) of the
+            largest kind.  It must also be sufficiently aligned for
+            assigning any type we use into it.  */
+         char value[32]  __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
          GFC_IO_INT size_used;
        } p;
       /* This pad size must be equal to the pad_size declared in
index c19d684b1072ed6fa3e429a195ede3927e47c0e6..23a8fa3019dd49a6448d383148fac611bb95c121 100644 (file)
@@ -126,8 +126,10 @@ max_value (int length, int signed_flag)
 
 /* convert_real()-- Convert a character representation of a floating
  * point number to the machine number.  Returns nonzero if there is a
- * range problem during conversion.  TODO: handle not-a-numbers and
- * infinities.  */
+ * range problem during conversion.  Note: many architectures
+ * (e.g. IA-64, HP-PA) require that the storage pointed to by the dest
+ * argument is properly aligned for the type in question.  TODO:
+ * handle not-a-numbers and infinities.  */
 
 int
 convert_real (st_parameter_dt *dtp, void *dest, const char *buffer, int length)