digitalmars.D.bugs - [Issue 1204] New: segfault using struct in CTFE
- d-bugmail puremagic.com (51/51) Apr 30 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1204
- d-bugmail puremagic.com (14/14) May 06 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1204
- d-bugmail puremagic.com (22/22) May 19 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1204
- d-bugmail puremagic.com (9/9) Jul 01 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1204
http://d.puremagic.com/issues/show_bug.cgi?id=1204
Summary: segfault using struct in CTFE
Product: D
Version: 1.013
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: clugdbug yahoo.com.au
Seems to be a memory corruption problem. Doesn't happen if unused, unused2 are
removed.
---------
struct V {
int a;
int b;
}
V f()
{
int q = 0;
int unused;
int unused2;
return V(q, 0);
}
void main()
{
const w = f();
}
==========================
Probably more helpful is this version, which prints:
No expression copy for: unused
just before it crashes.
------------------------
struct V {
int a;
int b;
}
V f()
{
int q = 0;
int unused;
int unused2;
return V(q, 0);
}
void main()
{
const w = f().b;
}
--
Apr 30 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1204
thomas-dloop kuehne.cn changed:
What |Removed |Added
----------------------------------------------------------------------------
OS/Version|Windows |All
DMD-1.014 on Linux doesn't crash but results in incorrect values for V.a and
V.b.
Added to DStress as
http://dstress.kuehne.cn/run/s/struct_30_A.d
http://dstress.kuehne.cn/run/s/struct_30_B.d
http://dstress.kuehne.cn/compile/s/struct_30_C.d
http://dstress.kuehne.cn/compile/s/struct_30_D.d
--
May 06 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1204
Another example or problem with struct and char literals in CTFE:
import std.stdio;
struct Col2Spec {
char[] type;
char[] name;
}
char[] f() {
char[] id = "x", id2 = "y";
Col2Spec a = Col2Spec(id,"a"); // error in CTFE
// Col2Spec a = Col2Spec("b",id2); // works
int i = 2;
assert(i - i, "Should be 'a', is " ~ a.name); // output, line: 13
return "ret";
}
void main() {
const static char[] w = f(); // line: 18
// f(); // works
}
// sb.d(18): Error: cannot evaluate f() at compile time
--
May 19 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1204
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Fixed DMD 1.018 and DMD 2.002
--
Jul 01 2007









d-bugmail puremagic.com 