Solution to "statement is not reachable" depending on template variables?

tsbockman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 16 18:42:38 PDT 2016


On Wednesday, 16 March 2016 at 11:18:36 UTC, Johan Engelen wrote:
> Hi all,
>   I've found discussions, but not an actual "recommended" 
> solution for the problem of "statement is not reachable" 
> warnings in templates with early returns...

"statement is not reachable" is fundamentally broken in D for 
generic code:
     https://issues.dlang.org/show_bug.cgi?id=14835

It's mostly not too big of a deal right now, only because the D 
front end's value range propagation capabilities are very weak.

Lionello Lunesu made a pull request a while back that majorly 
improves VRP in D as a part of his efforts to fix DMD issue 259. 
I decided to port it to DDMD a few months ago, and in the process 
discovered that with decent VRP, issue 14835 becomes 10-100x 
worse.

There was a forum discussion a while back as to what should be 
done about this, but unfortunately the conclusion was that it 
probably cannot really be fixed with any reasonable effort:
     
http://forum.dlang.org/thread/bnzfuekewfguvnwdznfk@forum.dlang.org

As far as I can tell, the only reasonable way forward is to 
simply remove the warning entirely (or ban meaningful upgrades to 
VRP).


More information about the Digitalmars-d-learn mailing list