Re: Superfluous code in switch statement

2015-09-05 Thread Paul via Digitalmars-d-learn
On Friday, 4 September 2015 at 21:20:11 UTC, Timon Gehr wrote: On 09/04/2015 11:12 PM, anonymous wrote: On Friday 04 September 2015 23:04, Timon Gehr wrote: DMD never warns about dead code. It warns here: import std.stdio; void main() { return; writeln("hi"); /* Warning:

Re: Superfluous code in switch statement

2015-09-04 Thread anonymous via Digitalmars-d-learn
On Friday 04 September 2015 23:04, Timon Gehr wrote: > DMD never warns about dead code. It warns here: import std.stdio; void main() { return; writeln("hi"); /* Warning: statement is not reachable */ }

Superfluous code in switch statement

2015-09-04 Thread Paul via Digitalmars-d-learn
I discovered the other day (during a cut and paste malfunction!) that it's possible to have code before the first case in a switch. Google tells me that it's legal C code and something I read said it could be used for initialization but was rather vague. void main() { import std.stdio;

Re: Superfluous code in switch statement

2015-09-04 Thread Timon Gehr via Digitalmars-d-learn
On 09/04/2015 09:39 PM, Paul wrote: I discovered the other day (during a cut and paste malfunction!) that it's possible to have code before the first case in a switch. Google tells me that it's legal C code and something I read said it could be used for initialization but was rather vague. void

Re: Superfluous code in switch statement

2015-09-04 Thread Timon Gehr via Digitalmars-d-learn
On 09/04/2015 11:12 PM, anonymous wrote: On Friday 04 September 2015 23:04, Timon Gehr wrote: DMD never warns about dead code. It warns here: import std.stdio; void main() { return; writeln("hi"); /* Warning: statement is not reachable */ } You are right, it does.