summaryrefslogtreecommitdiff
path: root/compar.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-01-31 15:25:09 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-02-06 11:46:51 +0900
commitb223a78a71b9f000315d70987d600661420f9475 (patch)
treec30a1d470998de1efb81e84fc623b6937fd1d06a /compar.c
parent34fd7241e445764837ec9fc700af65a0f73e8ce5 (diff)
downloadruby-b223a78a71b9f000315d70987d600661420f9475.tar.gz
this ternary operator is an undefined behaviour
Let me quote ISO/IEC 9899:2018 section 6.5.15: > Constraints > > The first operand shall have scalar type. > One of the following shall hold for the second and third operands: > — both operands have arithmetic type; > — both operands have the same structure or union type; > — both operands have void type; (snip) Here, `*option` is a const struct rb_compile_option_struct. OTOH `COMPILE_OPTION_DEFAULT` is a struct rb_compile_option_struct, without const. These two are _not_ the "same structure or union type". Hence the expression renders undefined behaviour. COMPILE_OPTION_DEFAULT is not a const because `RubyVM::InstructionSequence.compile_option=` touches its internals on-the-fly. There is no way to meet the constraints quoted above. Using ternary operator here was a mistake at the first place. Let's just replace it with a normal `if` statement.
Diffstat (limited to 'compar.c')
0 files changed, 0 insertions, 0 deletions