Bug 14510 – Bad tail call optimization with static arrays

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2015-04-27T03:39:00Z
Last change time
2017-07-22T12:35:43Z
Keywords
wrong-code
Assigned to
nobody
Creator
dlang-bugzilla
See also
https://issues.dlang.org/show_bug.cgi?id=14480

Comments

Comment #0 by dlang-bugzilla — 2015-04-27T03:39:13Z
Assertion fails with -O -m64 : ////////////////// test.d ////////////////// alias Vector = ulong[3]; void fun(Vector vec, bool recursive = false) { assert(vec[2] == 0); if (recursive) return; fun(vec, true); } void main() { Vector vec; fun(vec); } ////////////////////////////////////////////
Comment #1 by bugzilla — 2015-06-27T04:41:15Z
Comment #2 by github-bugzilla — 2015-06-27T06:13:14Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/af82ac6208a576ddae3bfab6b3ec2e4c211015a3 fix Issue 14510 - Bad tail call optimization with static arrays https://github.com/D-Programming-Language/dmd/commit/6071f1dbd7c5d70d9b0c4781e8d5efad0f6d95c6 Merge pull request #4778 from WalterBright/fix14510 Critical: fix Issue 14510 - Bad tail call optimization with static arrays
Comment #3 by github-bugzilla — 2015-07-01T01:25:12Z
Commit pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/86757a2f4efc5562d8621207676d2a187e91b33a Merge pull request #4778 from WalterBright/fix14510 Critical: fix Issue 14510 - Bad tail call optimization with static arrays
Comment #4 by github-bugzilla — 2015-07-24T03:20:15Z
Comment #5 by tbanelwebmin — 2015-08-30T13:02:31Z
I came across something similar. The following program crashes on assert, but only when compiled with -O DMD64 D Compiler v2.068.0 ---------------------------- struct SomeStruct { void fff (int n) { SomeStruct next; assert (&next != &this); if (n) next.fff(n-1); } } void main() { SomeStruct root; root.fff(2); } ---------------------------- As a workaround, add return 3; at the end of fff and change void to int
Comment #6 by github-bugzilla — 2015-10-04T18:18:44Z
Comment #7 by github-bugzilla — 2017-07-22T12:35:43Z
Commits pushed to dmd-cxx at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/af82ac6208a576ddae3bfab6b3ec2e4c211015a3 fix Issue 14510 - Bad tail call optimization with static arrays https://github.com/dlang/dmd/commit/6071f1dbd7c5d70d9b0c4781e8d5efad0f6d95c6 Merge pull request #4778 from WalterBright/fix14510