[Issue 13010] Use variable range propagation (VRP) for static assert
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Jul 1 00:55:06 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13010
bearophile_hugs at eml.cc changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bearophile_hugs at eml.cc
--- Comment #5 from bearophile_hugs at eml.cc ---
(In reply to Kenji Hara from comment #4)
> By advancing the thought, compiler will be able to generate "statement is
> not reachable" warning in else branch of the code.
>
> void test(ubyte n)
> {
> immutable int i = n;
> if (i >= 0) // const-folding with VRP will optimize the condition to
> true.
> { ... }
> else
> { ... } // so the else branch could be determined to "not reachable"
> }
Looks nice :-) I guess this will generate few nice warnings in Phobos and in D
code around.
--
More information about the Digitalmars-d-bugs
mailing list