Project

General

Profile

Bug #11790

[PATCH] ANSI alias rules fix

Added by Zarko (Zarko Todorovski) over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:71953]

Description

line 70 in file regparse.h:

#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

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:

-#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) alias_ansi_rule.patch Zarko (Zarko Todorovski), 12/08/2015 04:27 PM

Related issues

Related to Ruby trunk - Misc #11795: [PATCH] get rid of breaking strict alias for XL compilerClosedActions

Associated revisions

Revision 1263f82a
Added by nobu (Nobuyoshi Nakada) over 3 years ago

regparse.h: ANSI alias rule fix

  • regparse.h (SET_NTYPE): get rid of breaking strict aliasing. patch by Zarko Todorovski in [ruby-core:71953]. [Bug #11790]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 52999
Added by nobu (Nobuyoshi Nakada) over 3 years ago

regparse.h: ANSI alias rule fix

  • regparse.h (SET_NTYPE): get rid of breaking strict aliasing. patch by Zarko Todorovski in [ruby-core:71953]. [Bug #11790]

Revision 52999
Added by nobu (Nobuyoshi Nakada) over 3 years ago

regparse.h: ANSI alias rule fix

  • regparse.h (SET_NTYPE): get rid of breaking strict aliasing. patch by Zarko Todorovski in [ruby-core:71953]. [Bug #11790]

Revision 52999
Added by nobu (Nobuyoshi Nakada) over 3 years ago

regparse.h: ANSI alias rule fix

  • regparse.h (SET_NTYPE): get rid of breaking strict aliasing. patch by Zarko Todorovski in [ruby-core:71953]. [Bug #11790]

Revision 52999
Added by nobu (Nobuyoshi Nakada) over 3 years ago

regparse.h: ANSI alias rule fix

  • regparse.h (SET_NTYPE): get rid of breaking strict aliasing. patch by Zarko Todorovski in [ruby-core:71953]. [Bug #11790]

Revision 52999
Added by nobu (Nobuyoshi Nakada) over 3 years ago

regparse.h: ANSI alias rule fix

  • regparse.h (SET_NTYPE): get rid of breaking strict aliasing. patch by Zarko Todorovski in [ruby-core:71953]. [Bug #11790]

History

Updated by nobu (Nobuyoshi Nakada) over 3 years ago

  • Description updated (diff)

Does CAS work?

  /* THREAD_ATOMIC_START; */
  {
    FreeNode *n = FreeNodeList, *n0;
    while (IS_NOT_NULL(n) && (n0 = ATOMIC_PTR_CAS(FreeNodeList, n, n->next)) != n)
      n = n0;
    if (IS_NOT_NULL(n)) return (Node* )n;
  }
  /* THREAD_ATOMIC_END; */
#2

Updated by nobu (Nobuyoshi Nakada) over 3 years ago

  • Status changed from Open to Closed

Applied in changeset r52999.


regparse.h: ANSI alias rule fix

  • regparse.h (SET_NTYPE): get rid of breaking strict aliasing. patch by Zarko Todorovski in [ruby-core:71953]. [Bug #11790]
#3

Updated by naruse (Yui NARUSE) over 3 years ago

  • Related to Misc #11795: [PATCH] get rid of breaking strict alias for XL compiler added

Also available in: Atom PDF