String switch is odd using betterC

Petar Petar
Wed Feb 26 08:58:06 UTC 2020


On Wednesday, 26 February 2020 at 08:32:50 UTC, Abby wrote:
> On Wednesday, 26 February 2020 at 08:25:00 UTC, Abby wrote:
>> Any idea why?
>
> Ok so this is enough to produce the same result, it seems that 
> there is a problem in string switch when there is more the 6 
> cases.
>
> extern(C) void main()
> {
>     auto s = "F";
>     final switch(s)
>     {
>         case "A": break;
>         case "B": break;
>         case "C": break;
>         case "D": break;
>         case "E": break;
>         case "F": break;
>         case "G": break;
>     }
> }

This looks like a possible cause:
https://github.com/dlang/druntime/blob/e018a72084e54ecc7466e97c96e4557b96b7f905/src/core/internal/switch_.d#L34



More information about the Digitalmars-d-learn mailing list