www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2065] New: Return value of std.file.exists() is inverted.

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

           Summary: Return value of std.file.exists() is inverted.
           Product: D
           Version: 2.014
          Platform: PC
               URL: http://dsource.org/projects/phobos/changeset/683
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: andrei metalanguage.com
        ReportedBy: torhu yahoo.com


In r683, the Windows version of this function is changed into return the wrong
value.

The correct return statement would be "return result != 0xFFFFFFFF;"

The relevant docs:
http://msdn.microsoft.com/en-us/library/aa915578.aspx


-- 
May 02 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2065


andrei metalanguage.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED






 In r683, the Windows version of this function is changed into return the wrong
 value.
 
 The correct return statement would be "return result != 0xFFFFFFFF;"
 
 The relevant docs:
 http://msdn.microsoft.com/en-us/library/aa915578.aspx
Ouch. How did that ever go through? The fix will go into the next release. Thanks! --
May 03 2008
prev sibling next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2065






I'm having a hard time seeing how:

return (result == 0xFFFFFFFF) ? 0 : 1;

is different from:

return result != 0xFFFFFFFF;


-- 
May 12 2008
parent "Janice Caron" <caron800 googlemail.com> writes:
On 12/05/2008, d-bugmail puremagic.com <d-bugmail puremagic.com> wrote:
  I'm having a hard time seeing how:

  return (result == 0xFFFFFFFF) ? 0 : 1;

  is different from:

  return result != 0xFFFFFFFF;
It's certainly conceptually different. The first one returns an int, with possible values 0 and 1. The second one returns a bool with possible values false and true.
May 12 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2065







 I'm having a hard time seeing how:
 
 return (result == 0xFFFFFFFF) ? 0 : 1;
 
 is different from:
 
 return result != 0xFFFFFFFF;
I see that revision 682 and before had: return (result == 0xFFFFFFFF) ? 0 : 1; which is correct. In revision 683 I fixed exists to return bool instead of int (just like $DEITY intended it) and in the process I introduced the bug: return result == 0xFFFFFFFF; The one I recently checked into dsource has: return result != 0xFFFFFFFF; which should fix the bug. Sorry for the mistake. --
May 12 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2065







 On 12/05/2008, d-bugmail puremagic.com <d-bugmail puremagic.com> wrote:
  I'm having a hard time seeing how:

  return (result == 0xFFFFFFFF) ? 0 : 1;

  is different from:

  return result != 0xFFFFFFFF;
It's certainly conceptually different. The first one returns an int, with possible values 0 and 1. The second one returns a bool with possible values false and true.
In fact it seems the constants 0 and 1 are implicitly convertible to bool but no other integral values, which is a nice touch. I tried this program and was pleasantly surprised: void main() { bool a = 0; bool b = 1; bool c = 2; } It does not compile, but it does if you remove the definition of c. This is the kind of smarts that I'd like to extend to inferring data ranges and signedness. --
May 12 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2065


andrei metalanguage.com changed:

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





Fixed in 2.014.


-- 
May 17 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2065






Fixed dmd 1.030 and 2.014


-- 
May 22 2008