libgfortran patch for PR target/23556 (strict alignment fix)

Steve Ellcey sje@cup.hp.com
Wed Aug 31 17:18:00 GMT 2005


> > OK for checkin?
> 
> OK for both mainline and 4.0 (assuming you tested it on both).
> 
> The same problem also occurs in set_integer.  The identical fix
> would qualify as obvious after committing this one.

FYI:  Here is the set_integer patch I tested and am checking in on the
mainline.  I am still working on building and testing the 4.0 branch
versions.


2005-08-31  Steve Ellcey  <sje@cup.hp.com>

	* io/read.c (set_integer): Use memcpy to fill buffer.


*** gcc.orig/libgfortran/io/read.c	Wed Aug 31 09:59:19 2005
--- gcc/libgfortran/io/read.c	Wed Aug 31 09:59:38 2005
*************** set_integer (void *dest, GFC_INTEGER_LAR
*** 49,68 ****
      {
  #ifdef HAVE_GFC_INTEGER_16
      case 16:
!       *((GFC_INTEGER_16 *) dest) = value;
        break;
  #endif
      case 8:
!       *((GFC_INTEGER_8 *) dest) = value;
        break;
      case 4:
!       *((GFC_INTEGER_4 *) dest) = value;
        break;
      case 2:
!       *((GFC_INTEGER_2 *) dest) = value;
        break;
      case 1:
!       *((GFC_INTEGER_1 *) dest) = value;
        break;
      default:
        internal_error ("Bad integer kind");
--- 49,83 ----
      {
  #ifdef HAVE_GFC_INTEGER_16
      case 16:
!       {
! 	GFC_INTEGER_16 tmp = value;
! 	memcpy (dest, (void *) &tmp, length);
!       }
        break;
  #endif
      case 8:
!       {
! 	GFC_INTEGER_8 tmp = value;
! 	memcpy (dest, (void *) &tmp, length);
!       }
        break;
      case 4:
!       {
! 	GFC_INTEGER_4 tmp = value;
! 	memcpy (dest, (void *) &tmp, length);
!       }
        break;
      case 2:
!       {
! 	GFC_INTEGER_2 tmp = value;
! 	memcpy (dest, (void *) &tmp, length);
!       }
        break;
      case 1:
!       {
! 	GFC_INTEGER_1 tmp = value;
! 	memcpy (dest, (void *) &tmp, length);
!       }
        break;
      default:
        internal_error ("Bad integer kind");



More information about the Gcc-patches mailing list