[Issue 15585] VRP incorrectly assumes that out-of-range dchar values don't exist

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Oct 12 09:46:00 PDT 2016


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

--- Comment #3 from thomas.bockman at gmail.com ---
(In reply to Andrei Alexandrescu from comment #2)
> Thomas, do you have a code sample that illustrates the problem?

Sorry; I linked you to this issue by accident. Issue 14835 is the blocker that
I mentioned. That said...

bool isValidDChar(dchar cp)
{
    if (cp > dchar.max)
        return false;
    else
        return true;
}

The compiler automatically assumes that (cp <= dchar.max), always. So, *IF* VRP
propagated to comparisons, this function would be "optimized" to always return
true - which it should not, because it's quite easy to generate dchar values
that are greater than dchar.max, even in valid code.

However, VRP isn't currently used for compile-time evaluation of comparisons,
so there is (to my knowledge) no way to trigger this issue without my VRP
upgrade PR ( https://github.com/dlang/dmd/pull/5229 ).

It's a non-issue; the latest version of that PR already includes the fix for
this, so no-one but me should ever be bothered by it, I hope.

--


More information about the Digitalmars-d-bugs mailing list