[Issue 8886] New: [CTFE] a check failure of memory block inclusion
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 24 09:29:17 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8886
Summary: [CTFE] a check failure of memory block inclusion
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: CTFE
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2012-10-24 09:29:15 PDT ---
>From the comment at https://github.com/D-Programming-Language/druntime/pull/335
---
version = bug;
bool foo(const(int)[] a, const(int)[] b)
{
version(bug) {
return a.length &&
b.ptr >= a.ptr &&
b.ptr + b.length <= a.ptr + a.length;
} else {
if (a.length && b.length)
{
auto bend = b.ptr + b.length;
auto aend = a.ptr + a.length;
return a.ptr <= b.ptr && bend <= aend;
}
return false;
}
}
bool bug1()
{
auto a1 = [1,2,3,4,5];
return foo(a1[0..4], a1[2..4]);
}
bool bug2()
{
auto a1 = [1,2,3,4,5];
auto a2 = [1,2,3,4,5];
return foo(a1[0..4], a2[2..4]);
}
static assert( bug1());
static assert(!bug2()); // Fails CTFE when version = bug; defines.
---
--
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