From 98cd8256afa26fdcf4c4a7b01e4199fb47b2898d Mon Sep 17 00:00:00 2001 From: Steve Ellcey Date: Wed, 7 Sep 2005 20:16:47 +0000 Subject: [PATCH] re PR libfortran/23419 (unformatted complex I/O with kind=10) PR libfortran/23419 * io/write.c (extract_int): Use memcpy to access buffer. (extract_uint): Ditto. (extract_real): Ditto. From-SVN: r104000 --- libgfortran/ChangeLog | 7 ++++ libgfortran/io/write.c | 84 +++++++++++++++++++++++++++++++++++------- 2 files changed, 77 insertions(+), 14 deletions(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 8cc1a03e70a..8b2bb625a46 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2005-09-07 Steve Ellcey + + PR libfortran/23419 + * io/write.c (extract_int): Use memcpy to access buffer. + (extract_uint): Ditto. + (extract_real): Ditto. + 2005-09-05 Thomas Koenig * io/list_read.c: Adjust size of of value to 32 (to hold diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index 74d0f9fa0ad..da9feb3e09e 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -79,20 +79,40 @@ extract_int (const void *p, int len) switch (len) { case 1: - i = *((const GFC_INTEGER_1 *) p); + { + GFC_INTEGER_1 tmp; + memcpy ((void *) &tmp, p, len); + i = tmp; + } break; case 2: - i = *((const GFC_INTEGER_2 *) p); + { + GFC_INTEGER_2 tmp; + memcpy ((void *) &tmp, p, len); + i = tmp; + } break; case 4: - i = *((const GFC_INTEGER_4 *) p); + { + GFC_INTEGER_4 tmp; + memcpy ((void *) &tmp, p, len); + i = tmp; + } break; case 8: - i = *((const GFC_INTEGER_8 *) p); + { + GFC_INTEGER_8 tmp; + memcpy ((void *) &tmp, p, len); + i = tmp; + } break; #ifdef HAVE_GFC_INTEGER_16 case 16: - i = *((const GFC_INTEGER_16 *) p); + { + GFC_INTEGER_16 tmp; + memcpy ((void *) &tmp, p, len); + i = tmp; + } break; #endif default: @@ -113,20 +133,40 @@ extract_uint (const void *p, int len) switch (len) { case 1: - i = (GFC_UINTEGER_1) *((const GFC_INTEGER_1 *) p); + { + GFC_INTEGER_1 tmp; + memcpy ((void *) &tmp, p, len); + i = (GFC_UINTEGER_1) tmp; + } break; case 2: - i = (GFC_UINTEGER_2) *((const GFC_INTEGER_2 *) p); + { + GFC_INTEGER_2 tmp; + memcpy ((void *) &tmp, p, len); + i = (GFC_UINTEGER_2) tmp; + } break; case 4: - i = (GFC_UINTEGER_4) *((const GFC_INTEGER_4 *) p); + { + GFC_INTEGER_4 tmp; + memcpy ((void *) &tmp, p, len); + i = (GFC_UINTEGER_4) tmp; + } break; case 8: - i = (GFC_UINTEGER_8) *((const GFC_INTEGER_8 *) p); + { + GFC_INTEGER_8 tmp; + memcpy ((void *) &tmp, p, len); + i = (GFC_UINTEGER_8) tmp; + } break; #ifdef HAVE_GFC_INTEGER_16 case 16: - i = (GFC_UINTEGER_16) *((const GFC_INTEGER_16 *) p); + { + GFC_INTEGER_16 tmp; + memcpy ((void *) &tmp, p, len); + i = (GFC_UINTEGER_16) tmp; + } break; #endif default: @@ -143,19 +183,35 @@ extract_real (const void *p, int len) switch (len) { case 4: - i = *((const GFC_REAL_4 *) p); + { + GFC_REAL_4 tmp; + memcpy ((void *) &tmp, p, len); + i = tmp; + } break; case 8: - i = *((const GFC_REAL_8 *) p); + { + GFC_REAL_8 tmp; + memcpy ((void *) &tmp, p, len); + i = tmp; + } break; #ifdef HAVE_GFC_REAL_10 case 10: - i = *((const GFC_REAL_10 *) p); + { + GFC_REAL_10 tmp; + memcpy ((void *) &tmp, p, len); + i = tmp; + } break; #endif #ifdef HAVE_GFC_REAL_16 case 16: - i = *((const GFC_REAL_16 *) p); + { + GFC_REAL_16 tmp; + memcpy ((void *) &tmp, p, len); + i = tmp; + } break; #endif default: