digitalmars.D.bugs - [Issue 3801] New: CTFE: this.arr[i] cannot be evaluated at compile time for structs
- d-bugmail puremagic.com (30/30) Feb 14 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3801
- d-bugmail puremagic.com (20/20) Feb 26 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3801
- d-bugmail puremagic.com (19/19) Feb 27 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3801
- d-bugmail puremagic.com (12/12) Mar 18 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3801
- d-bugmail puremagic.com (10/10) Mar 24 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3801
- d-bugmail puremagic.com (15/15) Apr 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3801
http://d.puremagic.com/issues/show_bug.cgi?id=3801
Summary: CTFE: this.arr[i] cannot be evaluated at compile time
for structs
Product: D
Version: 2.040
Platform: Other
OS/Version: Windows
Status: NEW
Severity: blocker
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: ludwig informatik.uni-luebeck.de
07:45:33 PST ---
A static array contained inside a struct is not accessible during CTFE. Because
of this, it seems impossible (since some versions) to define compile-time
constants of such structures (for example tuple vectors or matrices).
---
struct S {
int arr[1];
this(int x){
arr[0] = x; // (this.arr[0u]) = x cannot be evaluated at compile time
}
}
immutable S s_constant = S(1); // Error: cannot evaluate __ctmp1.this(1) at
compile time
---
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3801
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug yahoo.com.au
Severity|blocker |major
a.b[i]=c; isn't implemented in CTFE yet, but a.b=c; is, so I'm downgrading from
blocker. (It's still high priority, though).
Workaround:
struct S {
int arr[1];
this(int x){
int[1] z = x;
arr = z;
}
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 26 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3801
03:44:47 PST ---
Unfortunately, the workaround also errors out with (although I did not check a
current svn build):
test.d(6): Error: this.arr[] = cast(const(int[]))x cannot be evaluated at
compile time
But this gave me finally another idea, which seems to work:
struct test {
int[1] f;
this(int x){
int[] dst = f;
dst[0] = x;
}
}
[Now off to some code porting and finally trying out the recent features...
;-)]
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 27 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3801
Sönke Ludwig <ludwig informatik.uni-luebeck.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |http://d.puremagic.com/issu
| |es/show_bug.cgi?id=3984
23:46:33 PDT ---
Unfortunately, the workaround also does not work (compiles but generates
incorrect code): http://d.puremagic.com/issues/show_bug.cgi?id=3984.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 18 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3801
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|major |blocker
Yeah, there doesn't seem to be any workaround. Changing it back to blocker.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 24 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3801
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Fixed.
D1:
https://github.com/D-Programming-Language/dmd/commit/ef2a0f1da10331c4de102ca3e029ea1c1c1a46bf
D2:
https://github.com/D-Programming-Language/dmd/commit/0219a5f0dcc88076759a4c472582954d0fb804b0
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 08 2011









d-bugmail puremagic.com 