Switch ignores case (?)

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 23 10:34:28 PST 2016


On 11/23/16 1:03 PM, Chris wrote:
> On Wednesday, 23 November 2016 at 17:33:04 UTC, Steven Schveighoffer wrote:
>
>>
>> I tested this locally with different ideas. This definitely looks like
>> a codegen bug.
>>
>> I was able to reduce it to:
>>
>> void main()
>> {
>>     switch("'"d)
>>     {
>>     case "'"d:
>>         writeln("a");
>>         break;
>>     case "’"d:
>>         writeln("b");
>>         break;
>>     default:
>>         writeln("default");
>>     }
>> }
>>
>> prints "default"
>>
>> What seems to fix it is removing the case statement for the "smart
>> apostrophe". So I'd look there for where the bug is triggering.
>>
>
> Yep, removing one of the two cases works. I tried it with different
> versions of dmd back to 2.070.0, and it always gives me the same (wrong)
> result. I haven't tried ldc yet.
>

Please file here: https://issues.dlang.org/enter_bug.cgi

I think this has been there forever. Happens in 2.040 too (the earliest 
dmd I have on my system).

-Steve


More information about the Digitalmars-d-learn mailing list