Bug #12657
closed[PATCH] ANSI aliasing fix for XL compiler
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
Updated by shyouhei (Shyouhei Urabe) over 8 years ago
- 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?
Updated by Zarko (Zarko Todorovski) over 8 years ago
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.
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
- 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 '&'.
Updated by shyouhei (Shyouhei Urabe) over 8 years ago
Nobuyoshi Nakada wrote:
Does this patch really compile?
Yes, at least to me.
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
RBASIC_CLEAR_CLASS
doesn't use RBASIC_CLEAR_CLASS_RAW
, and the former only is used with r-values.
Sorry for the noise.
Updated by shyouhei (Shyouhei Urabe) over 8 years ago
- Status changed from Feedback to Closed
Applied in changeset r55831.
- internal.h (RBASIC_CLEAR_CLASS): Reroute ANSI C's strict
aliasing rule.
[ruby-core:74427][Bug #12191][ruby-core:76747][Bug #12657]
Updated by vo.x (Vit Ondruch) about 8 years ago
- Related to Bug #12191: Violation of ANSI aliasing rules causing problems while compiling added
Updated by vo.x (Vit Ondruch) about 8 years ago
- 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