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

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Feb 28 06:36:10 PST 2015


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 #9 from bearophile_hugs at eml.cc ---
(In reply to Lionello Lunesu from comment #8)

This doesn't compile:

ubyte x;
void main() {
    immutable int y = x;
    ubyte z = y;
    static assert(y >= 0);
}


But this compiles, so the compiler knows statically y can't be negative:

ubyte x;
void main() {
    immutable int y = x;
    ubyte z = y;
}

So accepting that static assert seems a small improvement, perhaps it's just a
matter of using the variable range knowledge inside static assert.

--


More information about the Digitalmars-d-bugs mailing list