mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
RBASIC_SET_CLASS_RAW: follow strict aliasing rule
Instead of rather euphemistic struct cast, just reomve the const qualifier and assign directly. According to ISO/IEC 9899:2018 section 6.5 paragraph 7, `VALUE` and `const VALUE` are allowed to alias (but two distinct structs are not, even when their structures are the same). [Bug #17540]
This commit is contained in:
parent
f7c342f875
commit
33dc0a070a
Notes:
git
2021-03-02 17:47:49 +09:00
1 changed files with 2 additions and 2 deletions
|
@ -47,8 +47,8 @@ MJIT_SYMBOL_EXPORT_END
|
|||
static inline void
|
||||
RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass)
|
||||
{
|
||||
struct { VALUE flags; VALUE klass; } *ptr = (void *)obj;
|
||||
ptr->klass = klass;
|
||||
const VALUE *ptr = &RBASIC(obj)->klass;
|
||||
*(VALUE *)ptr = klass;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
Loading…
Reference in a new issue