diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5FDtest.c | 6 | ||||
-rw-r--r-- | src/H5Tconv.c | 24 |
2 files changed, 22 insertions, 8 deletions
diff --git a/src/H5FDtest.c b/src/H5FDtest.c index dc9ad93..87d24b6 100644 --- a/src/H5FDtest.c +++ b/src/H5FDtest.c @@ -71,8 +71,6 @@ * VFD feature flags (which do not exist until the driver * is instantiated). * - * See test/Makefile.am for a list of the VFD strings. - * * This function is only intended for use in the test code. * * Return: TRUE (1) if the VFD supports SWMR I/O or vfd_name is @@ -82,10 +80,6 @@ * * This function cannot fail at this time so there is no * error return value. - * - * Programmer: Dana Robinson - * Fall 2014 - * *------------------------------------------------------------------------- */ hbool_t diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 5deae85..f6ab0d7 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -887,7 +887,17 @@ done: /* Macro defining action on source data which needs to be aligned (before main action) */ #define H5T_CONV_LOOP_PRE_SALIGN(ST) \ { \ - H5MM_memcpy(&src_aligned, src, sizeof(ST)); \ + /* The uint8_t * cast is required to avoid tripping over undefined behavior. \ + * \ + * The typed pointer arrives via a void pointer, which may have any alignment. \ + * We then cast it to a pointer to a type that is assumed to be aligned, which \ + * is undefined behavior (section 6.3.2.3 paragraph 7 of the C99 standard). \ + * In the past this hasn't caused many problems, but in some cases (e.g. \ + * converting long doubles on macOS), an optimizing compiler might do the \ + * wrong thing (in the macOS case, the conversion uses SSE, which has stricter \ + * requirements about alignment). \ + */ \ + H5MM_memcpy(&src_aligned, (const uint8_t *)src, sizeof(ST)); \ } /* Macro defining action on source data which doesn't need to be aligned (before main action) */ @@ -919,7 +929,17 @@ done: /* Macro defining action on destination data which needs to be aligned (after main action) */ #define H5T_CONV_LOOP_POST_DALIGN(DT) \ { \ - H5MM_memcpy(dst, &dst_aligned, sizeof(DT)); \ + /* The uint8_t * cast is required to avoid tripping over undefined behavior. \ + * \ + * The typed pointer arrives via a void pointer, which may have any alignment. \ + * We then cast it to a pointer to a type that is assumed to be aligned, which \ + * is undefined behavior (section 6.3.2.3 paragraph 7 of the C99 standard). \ + * In the past this hasn't caused many problems, but in some cases (e.g. \ + * converting long doubles on macOS), an optimizing compiler might do the \ + * wrong thing (in the macOS case, the conversion uses SSE, which has stricter \ + * requirements about alignment). \ + */ \ + H5MM_memcpy((uint8_t *)dst, &dst_aligned, sizeof(DT)); \ } /* Macro defining action on destination data which doesn't need to be aligned (after main action) */ |