[Issue 8830] New: [CTFE] Incorrect slicing with pointer from sliced array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 16 06:56:34 PDT 2012
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: nobody at puremagic.com
ReportedBy: monarchdodra at gmail.com
--- Comment #0 from monarchdodra at 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: -------
More information about the Digitalmars-d-bugs
mailing list