Bug 22930 – importC: switch statement should use default:break; if no default specified

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-25T12:15:41Z
Last change time
2022-03-29T11:31:13Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
duser

Comments

Comment #0 by duser — 2022-03-25T12:15:41Z
with "dmd -wi": int fn() { switch (1) { case 2: return 0; } return 0; // Warning: statement is not reachable } seems like any switch that doesn't have at least once case using break; or falling of the end will give this warning for code after it
Comment #1 by dlang-bot — 2022-03-29T04:23:19Z
@WalterBright created dlang/dmd pull request #13911 "fix Issue 22930 - ImportC: D default for switch is wrong for C" fixing this issue: - fix Issue 22930 - ImportC: D default for switch is wrong for C https://github.com/dlang/dmd/pull/13911
Comment #2 by dlang-bot — 2022-03-29T11:31:13Z
dlang/dmd pull request #13911 "fix Issue 22930 - ImportC: D default for switch is wrong for C" was merged into master: - dd3e323c64a504023d6aded55b281660bcd3abdb by Walter Bright: fix Issue 22930 - ImportC: D default for switch is wrong for C https://github.com/dlang/dmd/pull/13911