Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why fall through on switch statements?

fall statements Switch
0
10 Posted

Why fall through on switch statements?

0
10

Many people have asked for a requirement that there be a break between cases in a switch statement, that C’s behavior of silently falling through is the cause of many bugs. The reason D doesn’t change this is for the same reason that integral promotion rules and operator precedence rules were kept the same – to make code that looks the same as in C operate the same. If it had subtly different semantics, it will cause frustratingly subtle bugs.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123