Unreachable statement, do or do not, there is no try

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 9 23:01:17 PST 2015


On 2015-02-09 20:00, deadalnix wrote:
> DMD accept both :
> int foo() {
>    try {
>      throw new Exception("blah");
>    } catch(Exception e) {
>      return 25;
>    }
> }
>
> and
>
> int foo() {
>    try {
>      throw new Exception("blah");
>    } catch(Exception e) {
>      return 25;
>    }
>
>    return 42;
> }
>
> Which is it ? What are the rule for the unreachable statment ? It seems
> that DMD is capable of figuring out that the try never returns, or it
> would complain about missing return in the first case. But that do not
> seems consistent with not triggering the unreachable statement in case 2.

DMD will complain about the second example if warnings are enabled.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list