D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21431 - Incorrect maximum and actual number of cases in a switch case range is reported
Summary: Incorrect maximum and actual number of cases in a switch case range is reported
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords: diagnostic, pull
Depends on:
Blocks:
 
Reported: 2020-11-26 19:00 UTC by Max Samukha
Modified: 2021-09-09 07:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2020-11-26 19:00:19 UTC
256 is reported to be the maximum number of cases allowed in a case range:

void main() {
    switch (0) {
        case 0:..case 257:
        	break;
        default:
    }
}

onlineapp.d(7): Error: had 257 cases which is more than 256 cases in case range

The error message is wrong about both the maximum allowed number (which is actually 257) and the actual number of cases (258 in the example). Something is off by one.
Comment 1 Dlang Bot 2021-09-08 15:55:15 UTC
@dkorpel created dlang/dmd pull request #13058 "Fix issue 21431 - Incorrect maximum and actual number of cases in a switch case range is reported" fixing this issue:

- fix issue 21431 - Incorrect maximum and actual number of cases in a switch case range is reported

https://github.com/dlang/dmd/pull/13058
Comment 2 Walter Bright 2021-09-08 19:45:28 UTC
https://github.com/dlang/dlang.org/pull/3097
Comment 3 Dlang Bot 2021-09-09 07:15:41 UTC
dlang/dmd pull request #13058 "Fix issue 21431 - Incorrect maximum and actual number of cases in a switch case range is reported" was merged into master:

- c075c4e00a992ffe495837600b89a92943ccbbb5 by dkorpel:
  fix issue 21431 - Incorrect maximum and actual number of cases in a switch case range is reported

https://github.com/dlang/dmd/pull/13058