libgfortran patch for PR target/23556 (strict alignment fix)
Steve Ellcey
sje@cup.hp.com
Thu Sep 1 16:46:00 GMT 2005
> 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 patch I checked in on the 4.0 branch. I had to tweak
it a little due to source changes, but it is basically identical. I
checked in the convert_real and set_integer changes with a single patch
on the 4.0 branch.
Steve Ellcey
sje@cup.hp.com
2005-09-01 Steve Ellcey <sje@cup.hp.com>
PR target/23556
* io/read.c (convert_real): Use memcpy to fill buffer.
(set_integer): Use memcpy to fill buffer.
Index: read.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/read.c,v
retrieving revision 1.8.10.6
diff -c -p -r1.8.10.6 read.c
*** read.c 22 Jul 2005 19:11:28 -0000 1.8.10.6
--- read.c 1 Sep 2005 16:41:05 -0000
*************** set_integer (void *dest, int64_t value,
*** 48,63 ****
switch (length)
{
case 8:
! *((int64_t *) dest) = value;
break;
case 4:
! *((int32_t *) dest) = value;
break;
case 2:
! *((int16_t *) dest) = value;
break;
case 1:
! *((int8_t *) dest) = value;
break;
default:
internal_error ("Bad integer kind");
--- 48,75 ----
switch (length)
{
case 8:
! {
! int64_t tmp = value;
! memcpy (dest, (void *) &tmp, length);
! }
break;
case 4:
! {
! int32_t tmp = value;
! memcpy (dest, (void *) &tmp, length);
! }
break;
case 2:
! {
! int16_t tmp = value;
! memcpy (dest, (void *) &tmp, length);
! }
break;
case 1:
! {
! int8_t tmp = value;
! memcpy (dest, (void *) &tmp, length);
! }
break;
default:
internal_error ("Bad integer kind");
*************** convert_real (void *dest, const char *bu
*** 108,122 ****
switch (length)
{
case 4:
! *((float *) dest) =
#if defined(HAVE_STRTOF)
! strtof (buffer, NULL);
#else
! (float) strtod (buffer, NULL);
#endif
break;
case 8:
! *((double *) dest) = strtod (buffer, NULL);
break;
default:
internal_error ("Unsupported real kind during IO");
--- 120,139 ----
switch (length)
{
case 4:
! {
! float tmp =
#if defined(HAVE_STRTOF)
! strtof (buffer, NULL);
#else
! (float) strtod (buffer, NULL);
#endif
+ memcpy (dest, (void *) &tmp, length);
break;
case 8:
! {
! double tmp = strtod (buffer, NULL);
! memcpy (dest, (void *) &tmp, length);
! }
break;
default:
internal_error ("Unsupported real kind during IO");
More information about the Fortran
mailing list