Bug #12657 closed
[PATCH] ANSI aliasing fix for XL compiler
Added by Zarko (Zarko Todorovski) over 8 years ago.
Updated about 8 years ago.
Description
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
Description updated (diff )
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?
Shyouhei Urabe wrote:
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?
Yes, that should work.
Description updated (diff )
Status changed from Open to Feedback
Does this patch really compile?
cls
in RBASIC_CLEAR_CLASS
sometimes isn't an l-value, and should not be able to be the operand of unary '&'.
Nobuyoshi Nakada wrote:
Does this patch really compile?
Yes, at least to me.
RBASIC_CLEAR_CLASS
doesn't use RBASIC_CLEAR_CLASS_RAW
, and the former only is used with r-values.
Sorry for the noise.
Status changed from Feedback to Closed
Applied in changeset r55831.
Related to Bug #12191 : Violation of ANSI aliasing rules causing problems while compiling added
Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: REQUIRED
I checked that the patches fix the warnings in Ruby 2.2. BTW r55833 is required alongside of r55831
Also available in: Atom
PDF
Like 0
Like 0 Like 0 Like 0 Like 0 Like 0 Like 0 Like 0 Like 0