[Issue 11744] New: static array members should be individually initializable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Dec 14 13:10:31 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11744
Summary: static array members should be individually
initializable
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: monarchdodra at gmail.com
--- Comment #0 from monarchdodra at gmail.com 2013-12-14 13:10:22 PST ---
Not sure if actual Bug or ER.
Given a struct containing a static array, and initializing the *members* of
that static array:
//----
struct S
{
this(this){writeln("postblit");}
void opAssign(ref S other){writeln("opAssign");}
}
struct Bar
{
S[3] value;
this(S s)
{
writeln("begin");
value[0] = s; //init
value[1] = s; //assign
value[2] = s; //assign
writeln("end");
}
}
void main()
{
auto bar = Bar(S.init);
}
//----
Produces:
//----
postblit
opAssign
opAssign
//----
This means the compiler "sees" the first assignement is actually
initialization. However, for the subsequent "=", it doesn't.
This is probably because "value" is already tagged as initialized. I think
there should be a better granularity for that (single member granularity).
Also, for example:
//----
struct S
{
const(int[2]) value;
this(int)
{
value[0] = 0;
value[1] = 1; //HERE
}
}
//----
Error: multiple field value initialization
//----
I think such code should be valid initialization.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list