www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2940] New: null is null cannot be evaluated at compile time

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2940

           Summary: null is null cannot be evaluated at compile time
           Product: D
           Version: 1.042
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: patch, rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: clugdbug yahoo.com.au


static assert(null is null);
---
bug.d(1): Error: static assert  (null is null) is not evaluatable at compile t
ime

Whereas the code below compiles fine:
int main(){ 
   return (null is null);
}
---
This also applies to similar kinds of expressions, eg (null is typeid(int)).

The patch for this relies on my patch for 1524, otherwise you get an ICE with
"null is typeid(int)".


-- 
May 05 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2940





------- Comment #1 from clugdbug yahoo.com.au  2009-05-05 03:01 -------
PATCH in optimize.c, line 779, in IdentityExp::optimize(int result)
Just allow TOKnull as one of the parameters.

OLD:
    if (this->e1->isConst() && this->e2->isConst())
    {
        e = Identity(op, type, this->e1, this->e2);
    }
NEW:
    if ((this->e1->isConst() || this->e1->op == TOKnull) &&
(this->e2->isConst()|| this->e2->op == TOKnull))
    {
        e = Identity(op, type, this->e1, this->e2);
    }


-- 
May 05 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2940





------- Comment #2 from tomas famolsen.dk  2009-05-05 06:35 -------
Does things break if NullExp::isConst() was just implemented? After all, null
is constant...


-- 
May 05 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2940


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #3 from Walter Bright <bugzilla digitalmars.com>  2009-09-03
13:25:00 PDT ---
Fixed dmd 1.047 and 2.032

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2009