Bug 19473 – DMD Segfault on circular struct reference

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2018-12-10T16:18:04Z
Last change time
2018-12-16T20:53:44Z
Assigned to
No Owner
Creator
deadalnix

Comments

Comment #0 by deadalnix — 2018-12-10T16:18:04Z
DMD Segfault on the following sample code: struct A { P p; struct UTpl() { union { P p; } } alias U() = UTpl!(); } alias B = A.U!(); struct C { union D { B b; } } union P { C.D p; } I have not been able to reduce the sample case further and I'm not quite sure what's going on.
Comment #1 by deadalnix — 2018-12-10T17:01:36Z
Running on older version of DMD tells me it is a regression. 2.066.0 to 2.071.2: Failure with output: onlineapp.d(21): Error: union onlineapp.P no size yet for forward reference
Comment #2 by bugzilla — 2018-12-12T11:39:46Z
There's certainly an unresolvable circular thing going on here.
Comment #3 by bugzilla — 2018-12-12T23:26:12Z
It's an infinite loop trying to determine the sizes for: P => D => UTpl => P ... resulting in a stack overflow.
Comment #4 by bugzilla — 2018-12-12T23:58:29Z
Comment #5 by github-bugzilla — 2018-12-16T20:53:40Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/d2b6fc972aec7b5a518b437f4ec0f8e184d549be fix Issue 19473 - DMD Segfault on circular struct reference https://github.com/dlang/dmd/commit/5aa95b571b473666b9e68dd1cb07c8dd0b008925 Merge pull request #9072 from WalterBright/fix19473 fix Issue 19473 - DMD Segfault on circular struct reference