[Issue 13010] Use variable range propagation (VRP) for static assert

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jul 1 17:19:22 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13010

Brad Roberts <braddr at puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr at puremagic.com

--- Comment #5 from Brad Roberts <braddr at puremagic.com> ---
--- Comment originally 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