digitalmars.D.bugs - [Issue 1315] New: CTFE doesn't default initialise arrays of structs
- d-bugmail puremagic.com (35/35) Jul 05 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1315
- d-bugmail puremagic.com (9/9) Sep 28 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1315
http://d.puremagic.com/issues/show_bug.cgi?id=1315
Summary: CTFE doesn't default initialise arrays of structs
Product: D
Version: 1.018
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: clugdbug yahoo.com.au
Seems as though struct arrays aren't default initialised inside CTFE.
CTFE disallows concatenation to an unitialised struct array, also can't get the
length.
Workaround is easy - just initialise the array to [].
-----------
struct S {
int a;
}
int func()
{
/* This is OK
int [] q;
q ~=4;
*/
S [] s; // makes the next lines fail. (but S[] s = []; compiles).
s ~= S(7); // fails
return s.length; // this fails too
}
void main()
{
const int x = func();
}
--
Jul 05 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1315
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Fixed dmd 1.021 and 2.004
--
Sep 28 2007








d-bugmail puremagic.com