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

           Summary: [CTFE] Incorrect slicing with pointer from sliced
                    array
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: monarchdo...@gmail.com


--- Comment #0 from monarchdo...@gmail.com 2012-10-16 06:56:32 PDT ---
Minimal test case:

//----
import std.stdio;

string[] foo(string s)
{
  auto ss = s[1..$];
  auto l = ss.length;
  string s2 = ss.ptr[0..2];
  return [ss, s2];

}

void main()
{
  enum bar = foo("hello");
  writeln(bar);
}
//----

Creates:

//----
[
  "ello", //Sliced 1..$ of "hello"
  "hel"   // *should* be "ello"[0..2], but is actually "hello"[0..2]
]
//----

It would appear that when slicing a pointer extracted from a previously sliced,
array, it will slice from the first index of that *original* array.

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

Reply via email to