On Solaris dirent is defined druntime/src/core/sys/posix/dirent.d like this;
else version (Solaris)
{
struct dirent
{
ino_t d_ino;
off_t d_off;
ushort d_reclen;
char[1] d_name;
}
This commit;
Commit: 5e88b67808022adba692451791422cb9fd58b490 [5e88b67]
Parents: 0ff1cfe045
Author: Alexandru Jercaianu <[email protected]>
Date: Thursday, October 5, 2017 1:20:39 PM
Committer: Alexandru Jercaianu
minor code refactoring
introduced a regression with the following change;
- private this(string path, core.sys.posix.dirent.dirent* fd) @safe
+ private this(string path, core.sys.posix.dirent.dirent* fd) @trusted
{
import std.path : buildPath;
- static auto trustedStrlen(const char* str) @trusted
- {
- return core.stdc.string.strlen(str);
- }
-
- immutable len = trustedStrlen(&fd.d_name[0]);
+ fd.d_name[$ - 1] = 0;
+ immutable len = strlen(&fd.d_name[0]);
_name = buildPath(path, fd.d_name[0 .. len]);
Specifically the line fd.d_name[$ - 1] = 0; is equivalent to fd.d_name[0] = 0, thus len is always 0.
Comment #1 by edi33416 — 2018-12-12T11:11:18Z
By the looks of it, this PR https://github.com/dlang/phobos/pull/5838 also solves this issue.
Closing
*** This issue has been marked as a duplicate of issue 17962 ***
dlang/phobos pull request #6947 "[dmd-cxx] Backport Solaris and DragonflyBSD ports" was merged into dmd-cxx:
- 8a832d917ffe1bdc30acb249fd7ad5b61b1470e0 by Eduard Staniloiu:
Fix Issue 19133 - core.exception.rangeerror@std/file.d(3812)
https://github.com/dlang/phobos/pull/6947