Issue #12657 has been updated by Shyouhei Urabe.

Description updated

Thank you.  I think we don't need the #else part because the memset/memcpy should just work for all ANSI-compliant compilers.  Is it OK for me to merge your patch like that way?

----------------------------------------
Bug #12657: [PATCH] ANSI aliasing fix for XL compiler
https://bugs.ruby-lang.org/issues/12657#change-59977

* Author: Zarko  Todorovski
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.3.1
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
This is related to Bug #12191.

Changing in internal.h:983-985

from :

```
-#define RBASIC_CLEAR_CLASS(obj)        (((struct RBasicRaw *)((VALUE)(obj)))->klass = 0)
-#define RBASIC_SET_CLASS_RAW(obj, cls) (((struct RBasicRaw *)((VALUE)(obj)))->klass = (cls))
```

to:

```
#ifdef __ibmxl__
    #define RBASIC_SET_CLASS_RAW(obj, cls) memcpy(&((struct RBasicRaw *)((VALUE)(obj)))->klass, &(cls), sizeof(VALUE))
#else
    #define RBASIC_SET_CLASS_RAW(obj, cls) (((struct RBasicRaw *)((VALUE)(obj)))->klass = (cls))
#endif

#ifdef __ibmxl__
    #define RBASIC_CLEAR_CLASS(obj)        memset(&(((struct RBasicRaw *)((VALUE)(obj)))->klass), 0, sizeof(((struct RBasicRaw *)((VALUE)(obj)))->klass))
#else
    #define RBASIC_CLEAR_CLASS(obj)        (((struct RBasicRaw *)((VALUE)(obj)))->klass = 0)
#endif
```

This allows for ruby to build using XL compiler. Otherwise build fails because of ANSI aliasing issues. 

---Files--------------------------------
RBASIC_aliasing.patch (1.04 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>