On Wednesday, 23 November 2016 at 19:07:49 UTC, Chris wrote:
It has something to do with the smart quote, e.g.:
it is wrong binary search in `_d_switch_string()`.
strings for switch are lexically sorted, and compiler calls
`_d_switch_string()` to select one. the thing is that comparison
in `_d_switch_string()` is done with `memcmp()`. still not clear?
ok, let's see how cases are encoded:
body _d_switch_dstring()
'U0027' (ca)
table[0] = 1, 'U0027'
table[1] = 1, 'U2019'
or, in memory:
table[0] = 1, 0x27, 0x00
table[1] = 1, 0x19, 0x20
so, memcmp for `table[1]` returns... 1! 'cause 0x27 is greater
than 0x19. and binsearch is broken from here on. the same is true
for `_d_switch_ustring()`, of course.
this can be fixed either by using slow char-by-char comparisons
in druntime, or by fixing codegen, so it would sort strings as
byte arrays.