[Issue 5452] New: Signed file lengths and positions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 13 16:17:45 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5452

           Summary: Signed file lengths and positions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-01-13 16:15:53 PST ---
In File size() returns an ulong, given by seek():
http://www.dsource.org/projects/phobos/browser/trunk/phobos/std/stdio.d?rev=2284#L585
http://www.dsource.org/projects/phobos/browser/trunk/phobos/std/stdio.d?rev=2284#L1245

It uses fseek, that seems to return a signed value:
http://www.cplusplus.com/reference/clibrary/cstdio/ftell/

So isn't it better and safer if those functions of File return a long instead
of an ulong?

See also bug 3843 but here the values are 64 bit, so while 4 GB arrays of bytes
are possible, files of just 9_223_372_036_854_775_807 bytes are not a
significant limitation compared to files 18_446_744_073_709_551_615 bytes long.

Currently unsigned values are quite dangerous in D, so I suggest to avoid
introducing them in Phobos unless where they are necessary.

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


More information about the Digitalmars-d-bugs mailing list