From 44753cf5a30b9324d2c4ac9021843674bde5cc3c Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 15 Feb 2015 13:29:30 +0100 Subject: Do not generate code dereferencing type-punned pointers For variable-length arrays, up to 2048 bytes are transmitted inline. If the array is larger, the data is transmitted out-of-line, and a pointer to a vm_allocated region is stored at the beginning of the array. Previously, the generated code casted the field. Use a union instead. This fixes the gcc warning `dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]'. * global.c (OOLPostfix): New variable. * global.h (OOLPostfix): New declaration. * server.c (WriteServerCallArg): Avoid cast. (WriteDestroyArg): Likewise. (WritePackArgValue): Likewise. (WritePackArg): Likewise. * user.c (WriteExtractArgValue): Likewise. * utils.c (WriteFieldDeclPrim): Generate a union with an additional pointer field for variable-length arrays. --- global.c | 1 + 1 file changed, 1 insertion(+) (limited to 'global.c') diff --git a/global.c b/global.c index 0a938f2..5685186 100644 --- a/global.c +++ b/global.c @@ -48,6 +48,7 @@ const_string_t UserPrefix = ""; const_string_t ServerDemux = strNULL; const_string_t SubrPrefix = ""; const_string_t RoutinePrefix = ""; +const_string_t OOLPostfix = "P"; string_t yyinname; -- cgit v1.2.3