Bug 20092 – void[1] auto slicing makes the compiler hang
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-07-30T14:53:03Z
Last change time
2020-08-25T07:21:21Z
Keywords
ice, pull
Assigned to
No Owner
Creator
John Colvin
Comments
Comment #0 by john.loughran.colvin — 2019-07-30T14:53:03Z
void foo()
{
(void[1]).init.front;
}
void front(T)(T[] a) {}
hangs the compiler forever, chewing through memory.
Comment #1 by b2.temp — 2019-11-15T02:43:48Z
The loop happens in
dmd.optimize.Expression.Expression_optimize(Expression e, int result, bool keepLvalue)
But the background problem is that template parameter type deduction gives `ubyte ` instead of `void`. As a consequence the protections against infinite recursion when the optimizer visit a CastExpression don't work.
For example by rewriting the call in the test case this way
(void[1]).init.front!void;
that works but
(void[1]).init.front!ubyte;
loops...
Comment #2 by dlang-bot — 2019-11-16T06:59:25Z
@StianGulpen created dlang/dmd pull request #10571 "fix issue 20092 - void[1] auto slicing makes the compiler hang" fixing this issue:
- fix issue 20092 - void[1] auto slicing makes the compiler hang
https://github.com/dlang/dmd/pull/10571
Comment #3 by dlang-bot — 2019-11-25T15:39:57Z
dlang/dmd pull request #10571 "fix issue 20092 - void[1] auto slicing makes the compiler hang" was merged into stable:
- 738b5badd4b4395f7d2fce2e4b2a7c27b071be66 by Stian Gulpen:
fix issue 20092 - void[1] auto slicing makes the compiler hang
https://github.com/dlang/dmd/pull/10571
Comment #4 by dlang-bot — 2020-08-25T07:21:21Z
dlang/dmd pull request #11621 "[dmd-cxx] Fix Issue 20092 and Issue 20356 - recursive expansion/optimization fixes" was merged into dmd-cxx:
- 3cb450d070c5acffd0e848834ca3d34a585e0740 by Iain Buclaw:
[dmd-cxx] Fix Issue 20092 - void[1] auto slicing makes the compiler hang
Adds enum global.recursionLimit and uses it in all places where such
errors can occur.
https://github.com/dlang/dmd/pull/11621