D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20092 - void[1] auto slicing makes the compiler hang
Summary: void[1] auto slicing makes the compiler hang
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 critical
Assignee: No Owner
URL:
Keywords: ice, pull
Depends on:
Blocks:
 
Reported: 2019-07-30 14:53 UTC by John Colvin
Modified: 2020-08-25 07:21 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description John Colvin 2019-07-30 14:53:03 UTC
void foo()
{
    (void[1]).init.front;
}

void front(T)(T[] a) {}

hangs the compiler forever, chewing through memory.
Comment 1 basile-z 2019-11-15 02:43:48 UTC
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 Dlang Bot 2019-11-16 06:59:25 UTC
@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 Dlang Bot 2019-11-25 15:39:57 UTC
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 Dlang Bot 2020-08-25 07:21:21 UTC
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