On Wednesday, 23 November 2016 at 19:30:01 UTC, ketmar wrote:
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.

Actually, I came across a compiler message that gave me something like \x19\x20 which I found odd. This sure needs fixing. After all, it's quite a basic feature. So it's back to the old `if` again (for now).
  • Switch ignores case (?) Chris via Digitalmars-d-learn
    • Re: Switch ignores case ... Steven Schveighoffer via Digitalmars-d-learn
      • Re: Switch ignores c... Chris via Digitalmars-d-learn
        • Re: Switch ignor... Steven Schveighoffer via Digitalmars-d-learn
          • Re: Switch i... Chris via Digitalmars-d-learn
            • Re: Swi... Jonathan M Davis via Digitalmars-d-learn
            • Re: Swi... ketmar via Digitalmars-d-learn
              • Re:... Chris via Digitalmars-d-learn
                • ... ketmar via Digitalmars-d-learn
                • ... ketmar via Digitalmars-d-learn
              • Re:... Steven Schveighoffer via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... ketmar via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... ketmar via Digitalmars-d-learn
                • ... Chris via Digitalmars-d-learn
                • ... ketmar via Digitalmars-d-learn
                • ... Chris via Digitalmars-d-learn

Reply via email to