[Issue 9932] New: CTFE cannot be used when a struct has "uninitialized" static array union members?
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 14 11:22:17 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9932
Summary: CTFE cannot be used when a struct has "uninitialized"
static array union members?
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: simendsjo at gmail.com
--- Comment #0 from simendsjo <simendsjo at gmail.com> 2013-04-14 11:22:16 PDT ---
Ref: http://forum.dlang.org/thread/gegwzcaswemphdlcahfl@forum.dlang.org
Related to http://d.puremagic.com/issues/show_bug.cgi?id=8543 ?
----
This is probably not a minimal test-case, and I haven't tested
with more types, but it shows the problem.
// This works
struct S {
this(int i) {
a = i;
}
union {
int a = void;
int b = void;
}
}
unittest
{
auto s = S(1);
assert(&s.a == &s.b);
enum s2 = S(1);
static assert(S(1).a == 1);
}
// But this doesn't
struct S2 {
this(int i) { // error at this line
a[] = i;
}
union {
int[1] a = void;
int[1] b = void;
}
}
unittest
{
auto s = S2(1);
assert(s.a.ptr == s.b.ptr);
// bug.d(19): Error: uninitialized variable 'b' cannot be
returned from CTFE
enum s2 = S2(1);
}
void main() {
}
--
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