Bug 19089 – Compiler crash for using struct &this

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-07-16T23:02:30Z
Last change time
2020-07-10T14:25:13Z
Keywords
CTFE, ice
Assigned to
uplink.coder
Creator
Ali Cehreli

Comments

Comment #0 by acehreli — 2018-07-16T23:02:30Z
The following code segfaults dmd 2.081.0: struct List { private List* l; this(int x) { l = &this; } } List ls = 0; void main() { } $ dmd --version DMD64 D Compiler v2.081.0 [...] $ dmd deneme.d Segmentation fault <-- HERE Forum discussion: https://forum.dlang.org/post/[email protected]
Comment #1 by b2.temp — 2018-07-18T11:16:43Z
"List l = 0;" is done at compile time. This shouldn't be allowed since there's a pointer operation. put "writeln(&this);" in the ctor to see an evidence.
Comment #2 by uplink.coder — 2018-07-19T12:56:53Z
You are correct what happens here is infinite recursion inside the interpreter. I am going to investigate.
Comment #3 by uplink.coder — 2018-07-19T12:57:57Z
You are correct what happens here is infinite recursion inside the interpreter. I am going to investigate.
Comment #4 by b2.temp — 2020-06-21T02:54:12Z
no ICE anymore when using latest release or latest master
Comment #5 by ibuclaw — 2020-07-10T14:25:13Z
Has the test been added to the testsuite?