digitalmars.D.bugs - [Issue 5258] New: [CTFE] Stack overflow with struct by ref
- d-bugmail puremagic.com (32/32) Nov 22 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5258
- d-bugmail puremagic.com (53/53) May 06 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5258
- d-bugmail puremagic.com (10/10) May 06 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5258
- d-bugmail puremagic.com (6/6) May 17 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5258
- d-bugmail puremagic.com (11/11) May 27 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5258
- d-bugmail puremagic.com (10/10) Jun 11 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5258
http://d.puremagic.com/issues/show_bug.cgi?id=5258 Summary: [CTFE] Stack overflow with struct by ref Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc This D2 program generates a Stack Overflow with DMD 2.050 despite the stack dept is very small: struct Foo { int x; } void bar(int n, ref Foo f) { if (n) bar(n - 1, f); else f.x++; } int spam() { bar(1, Foo()); return 0; } enum _ = spam(); void main() {} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 22 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5258 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |regression This CTFE bug is present in DMD v1.068beta still, but it seems absent in DMD v1.042. A longer example that gives the correct answer with DMD 1.042 but produces stack overflow with DMD v1.068beta: import std.c.stdio: printf; bool test(int k, int j, ulong diag45, ulong diag135, ulong cols) { return ((cols & (1UL << j)) + (diag135 & (1UL << (j + k))) + (diag45 & (1UL << (32 + j - k))) ) == 0; } void mark(int k, int j, ref ulong diag45, ref ulong diag135, ref ulong cols) { cols ^= (1UL << j); diag135 ^= (1UL << (j + k)); diag45 ^= (1UL << (32 + j - k)); } uint solve(int niv, int dx, ref ulong diag45, ref ulong diag135, ref ulong cols) { uint solutions_found; if (niv) { for (int i = 0; i < dx; i++) if (test(niv, i, diag45, diag135, cols)) { mark(niv, i, diag45, diag135, cols); solutions_found += solve(niv - 1, dx, diag45, diag135, cols); mark(niv, i, diag45, diag135, cols); } } else { for (int i = 0; i < dx; i++) solutions_found += test(0, i, diag45, diag135, cols); } return solutions_found; } ulong nqueen(int n) { // masques ulong diag45 = 0; // / diagonal bitboard ulong diag135 = 0; // \ diagonal bitboard ulong cols = 0; // column bitboard return solve(n - 1, n, diag45, diag135, cols); } const ulong result = nqueen(9); void main() { // NQUEENS: 1, 0, 0, 2, 10, 4, 40, 92, 352, 724, 2_680, 14_200, 73_712, 365_596 printf("%lld\n", result); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 06 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5258 This is a pseudo-regression: it was never doing what it was supposed to. The test case happened to give the correct results on a previous version, but only because one bug hid another. Slight changes would make it fail. Ref parameters are not going to work reliably in CTFE until pointers are implemented. Which is not happening in this release. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 06 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5258 The bug reported in comment 1 is bug 5845, which is a different bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 17 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5258 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED https://github.com/D-Programming-Language/dmd/commit/ff385f5a931b52eea27430ae6d4c6658876f05f0 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 27 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5258 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |verylonglogin.reg gmail.com *** Issue 6131 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 11 2011