www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6281] New: [CTFE] A null pointer '!is null' returns 'true'.

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

           Summary: [CTFE] A null pointer '!is null' returns 'true'.
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: kennytm gmail.com



Test case:

------------------------
static assert(!{
    auto p = null;
    return p !is null;
}());
------------------------
x.d(1): Error: static assert  (!true) is false
------------------------

The problem is the strange statement 'cmp ^= -1' in
https://github.com/D-Programming-Language/dmd/blob/master/src/interpret.c#L2338.
When two pointers are both null, 'cmp' will be 1, and 'cmp ^ -1' is -2 which is
also true.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 10 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6281


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch





https://github.com/D-Programming-Language/dmd/pull/229

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 10 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6281


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au




 Test case:
 
 ------------------------
 static assert(!{
     auto p = null;
     return p !is null;
 }());
 ------------------------
 x.d(1): Error: static assert  (!true) is false
 ------------------------
 
 The problem is the strange statement 'cmp ^= -1' in
 https://github.com/D-Programming-Language/dmd/blob/master/src/interpret.c#L2338.
 When two pointers are both null, 'cmp' will be 1, and 'cmp ^ -1' is -2 which is
 also true.
IIRC that was copied from Equals() in constfold.c. The bug probably exists there as well. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 20 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6281


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



13:45:26 PDT ---
https://github.com/D-Programming-Language/dmd/commit/90f82ecf1376a20d39326c9033115f43fd8569dd

https://github.com/D-Programming-Language/dmd/commit/000097b71f8ed2be69be36c1094efe694fb82a72

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 26 2011