digitalmars.D.bugs - [Issue 6399] New: [CTFE] struct member array.length -= x doesn't work, while array[0..$-x] works
- d-bugmail puremagic.com (43/43) Jul 29 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6399
- d-bugmail puremagic.com (14/14) Jul 30 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6399
- d-bugmail puremagic.com (13/13) Jul 31 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6399
http://d.puremagic.com/issues/show_bug.cgi?id=6399
Summary: [CTFE] struct member array.length -= x doesn't work,
while array[0..$-x] works
Product: D
Version: D2
Platform: Other
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: dmitry.olsh gmail.com
07:05:49 PDT ---
It has something to do with structs, test case:
struct A{
int[] arr;
int subLen()
{
arr = [1,2,3, 4,5];
arr.length -= 1; //replace this line with a next and it compiles
// arr = arr[0..$-1];
return arr.length;
}
}
int getMeFour()
{
A a;
return a.subLen();
}
int getMeFour2()
{
auto arr = [1,2,3, 4,5];
arr.length -= 1;
return arr.length;
}
enum t1 = getMeFour();
enum t2 = getMeFour2();//this works regardless of -=x or [0..$-x]
static assert(t1 == 4);
static assert(t2 == 4);
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 29 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6399
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug yahoo.com.au
Actually array.length = array.length - x also works. It's only +=, -= that
fail.
It's because it gets changed into:
(tmp = &array, *(tmp).length = *(tmp.length)-x );
and (*p).length = n; isn't yet implemented.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 30 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6399
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |bugzilla digitalmars.com
Resolution| |FIXED
12:10:06 PDT ---
https://github.com/D-Programming-Language/dmd/commit/7ef3b2bb9e740df39108957ae5e3b2aa8253d351
https://github.com/D-Programming-Language/dmd/pull/284
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 31 2011









d-bugmail puremagic.com 