From 06aeded227d68bb8b3d1d6141830589017ec86de Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 15 May 2016 22:43:41 +0100 Subject: [PATCH] use memcpy for set_format_arg To get round strict aliasing problem. --- src/localisation/localisation.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/localisation/localisation.h b/src/localisation/localisation.h index b9731c10b2..b1f04f157e 100644 --- a/src/localisation/localisation.h +++ b/src/localisation/localisation.h @@ -63,6 +63,11 @@ extern const char *real_names[1024]; extern utf8 *gUserStrings; extern uint8 gCommonFormatArgs[80]; -#define set_format_arg(offset, type, value) ((*((type*)&gCommonFormatArgs[(offset)])) = (value)) +static inline void set_format_arg_body(size_t offset, uintptr_t value, size_t size) +{ + memcpy(gCommonFormatArgs + offset, &value, size); +} + +#define set_format_arg(offset, type, value) set_format_arg_body(offset, (uintptr_t)value, sizeof(type)) #endif