From: nobu@... Date: 2015-12-08T23:24:59+00:00 Subject: [ruby-core:71959] [Ruby trunk - Bug #11790] [PATCH] ANSI alias rules fix Issue #11790 has been updated by Nobuyoshi Nakada. Description updated Does CAS work? ~~~c /* THREAD_ATOMIC_START; */ { FreeNode *n = FreeNodeList, *n0; while (IS_NOT_NULL(n) && (n0 = ATOMIC_PTR_CAS(FreeNodeList, n, n->next)) != n) n = n0; return (Node* )FreeNodeList; } /* THREAD_ATOMIC_END; */ ~~~ ---------------------------------------- Bug #11790: [PATCH] ANSI alias rules fix https://bugs.ruby-lang.org/issues/11790#change-55369 * Author: Zarko Todorovski * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- line 70 in file regparse.h: ~~~c #define SET_NTYPE(node, ntype) (node)->u.base.type = (ntype) ~~~ needs to be changed to conform with ANSI alias rules Line 70 as it is can lead to errors in compiling in regparse.c ~~~c line 1143: node = (Node* )FreeNodeList; line 1144: FreeNodeList = FreeNodeList->next; line 1581: (node)->u.base.type = (0); ~~~ where during compiling line 1581 can be moved ahead of line 1144 since under ANSI aliasing rules, the compiler determines that the statement of "(node)->u.base.type = (0);" does not affect the value of FreeNodeList. Proposed change in patch is in file regparse.h: ~~~diff -#define SET_NTYPE(node, ntype) (node)->u.base.type = (ntype) +#define SET_NTYPE(node, ntype) {int value = ntype; memcpy(&((node)->u.base.type), &value, sizeof((node)->u.base.type));} ~~~ ---Files-------------------------------- alias_ansi_rule.patch (717 Bytes) -- https://bugs.ruby-lang.org/