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]

[patch] Fix PR19294


 Hi,

  The problem here is that complex(kind=4) is only aligned to 4 bytes, but
_gfortran_transpose_8 uses an 8 byte integer which is expected to be aligned
to 8 bytes on STRICT_ALIGNMENT targets.  Thus passing complex(kind=4) which
is aligned to 4 bytes and not 8 bytes causes a bus error in
_gfortran_transpose_8 which is what causes intrinsic_transpose.f90 to fail
on SPARC.  This patch gets complex types to use the generic transpose function,
thus fixing the problem.

  There is similar mucking of kind for complex types in gfc_resolve_reshape,
but I can't any bus errors out of any of the reshape functions.  The kind
mucking is actually ignored in gfc_resolve_reshape so it might be possible
to remove that chunk of code.  That is a different patch though.

 The attached patch has been bootstrapped and regtested on sparc-linux, Ok
for mainline?

--
Thanks,
Jim

http://www.student.cs.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim

2005-01-16  James A. Morrison  <phython@gcc.gnu.org>

	* iresolve.c (gfc_resolve_transpose): Use generic transpose
	for complex numbers on STRICT_ALIGNMENT targets.

Index: iresolve.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/iresolve.c,v
retrieving revision 1.28
diff -u -p -r1.28 iresolve.c
--- iresolve.c	15 Dec 2004 03:56:05 -0000	1.28
+++ iresolve.c	15 Jan 2005 00:45:30 -0000
@@ -1,5 +1,5 @@
 /* Intrinsic function resolution.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation,
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
    Inc.
    Contributed by Andy Vaught & Katherine Holcomb
 
@@ -31,6 +31,7 @@ Software Foundation, 59 Temple Place - S
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "tm.h"
 #include "tree.h"
 #include "gfortran.h"
 #include "intrinsic.h"
@@ -1343,7 +1347,10 @@ gfc_resolve_transpose (gfc_expr * f, gfc
   switch (matrix->ts.type)
     {
     case BT_COMPLEX:
-      kind = matrix->ts.kind * 2;
+      if (STRICT_ALIGNMENT)
+	kind = 0;
+      else
+	kind = matrix->ts.kind * 2;
       break;
 
     case BT_REAL:


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