D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22930 - importC: switch statement should use default:break; if no default specified
Summary: importC: switch statement should use default:break; if no default specified
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: ImportC, pull
Depends on:
Blocks:
 
Reported: 2022-03-25 12:15 UTC by duser
Modified: 2022-03-29 11:31 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description duser 2022-03-25 12:15:41 UTC
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 Dlang Bot 2022-03-29 04:23:19 UTC
@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 Dlang Bot 2022-03-29 11:31:13 UTC
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