[Issue 18017] [External] [DMC] File.size() uses a 32-bit signed integer for size internally (gives wrong results for files over ≈2.1 GB)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Nov 28 15:32:29 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=18017
Steven Schveighoffer <schveiguy at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schveiguy at yahoo.com
Hardware|x86_64 |x86
Summary|File.size() uses a 32-bit |[External] [DMC]
|signed integer for size |File.size() uses a 32-bit
|internally (gives wrong |signed integer for size
|results for files over ≈2.1 |internally (gives wrong
|GB) |results for files over ≈2.1
| |GB)
--- Comment #1 from Steven Schveighoffer <schveiguy at yahoo.com> ---
The issue here is that DMC's 32-bit ftell returns a 32-bit signed value, and
this translates to int.min here.
Then phobos translates that to an unsigned long (64-bit).
The workaround is to simply use 64-bit C runtime (dmd -m64), which should work
properly.
But until DMC's clib can support 64-bit ftell, D can't do anything about this.
Sure we can treat values from int.min to -2 as unsigned, but that doesn't help
with 5GB files for instance.
One thing we *could* do is throw an error. But I'm not sure that's a
"solution". Nor am I sure that this workaround would work for files that are
larger than uint.max.
--
More information about the Digitalmars-d-bugs
mailing list