[Issue 4593] New: (DMD 2.047) std.string.split + unittest build = Access Violation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 7 08:14:52 PDT 2010


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

           Summary: (DMD 2.047) std.string.split + unittest build = Access
                    Violation
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: epi at atari8.info


--- Comment #0 from Adrian Matoga <epi at atari8.info> 2010-08-07 08:14:50 PDT ---
Hi,

I encountered a strange problem that appears when I build my project with
-unittest switch on.
The executable fails giving a message "object.Error: Access Violation",
despite that without "-unittest" it works correctly.

I tried to successively cut different parts of code to find a source of
problem, and I came up with an example which may be close to a minimal one.
It consists of two files, "a.d":

-------------------------
import std.string;
import std.stdio;

static string foo(string path)
{
    auto strs = path.split(".");
    return strs.length ? strs[$ - 1] : "";
}
-------------------------

and "b.d":

-------------------------
import std.stdio;
import a;

void main()
{
    writeln("Hello, world!");
}
-------------------------


Compile it using:
dmd -oftest.exe -unittest a.d b.d

and then launch it, and you'll see the "Access violation" message.
However, when you drop -unittest switch, or replace `path.split(".")' with, for
example, `[ "" ]', or merge both sources together into a single source file,
the program displays "Hello, world!" as expected.

I have no idea what could be the actual source of problem, but I hope the
example can help fixing it.

Regards,
Adrian Matoga

-- 
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