Thread overview
[Issue 6814] New: Calling std.file.readLink causes code to not compile.
Oct 15, 2011
Kapps
Oct 16, 2011
Jonathan M Davis
Oct 16, 2011
Jonathan M Davis
Jan 08, 2012
Brad Roberts
October 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6814

           Summary: Calling std.file.readLink causes code to not compile.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: opantm+spam@gmail.com


--- Comment #0 from Kapps <opantm+spam@gmail.com> 2011-10-15 16:57:39 PDT ---
The function std.file.readLink attempts to convert a char[2048] to a char* implicitly, causing any code calling it to result in a compiler error.

Test Case:

import std.stdio;
import std.file;

void main() {
        string Path = readLink("/proc/self/exe");
        writefln(Path);
}

Output:

/usr/include/d/dmd/phobos/std/file.d(1834): Error: function
core.sys.posix.unistd.readlink (in const(char*), char*, ulong) is not callable
using argument types (const(char*),char[2048LU],ulong)
/usr/include/d/dmd/phobos/std/file.d(1835): Error: cannot implicitly convert
expression (buffer) of type char[2048LU] to char*

Fix:
Just add a .ptr when calling the core.sys version.

As an unrelated issue, readLink will also truncate without warning if the path resolves to more than 2047 characters, but I'm not sure if that's worth opening a separate bug report for.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6814


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg@gmx.com


--- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-10-15 17:48:09 PDT ---
This is very bizarre, because the unit tests compile and run just fine for readLink. But your example does indeed fail to compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6814



--- Comment #2 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-10-15 18:31:26 PDT ---
https://github.com/D-Programming-Language/phobos/pull/294

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6814


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |braddr@puremagic.com
         Resolution|                            |FIXED


--- Comment #3 from Brad Roberts <braddr@puremagic.com> 2012-01-07 23:35:56 PST ---
Fix pulled back in Oct 2011.  Closing.

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