Bug 19152 – 2.081.1 getOverloads regression compiler bug

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-08-09T19:55:19Z
Last change time
2021-01-03T22:57:18Z
Keywords
pull
Assigned to
No Owner
Creator
Andre

Comments

Comment #0 by andre — 2018-08-09T19:55:19Z
Executing dub build for https://github.com/andre2007/delta-core-10-2-1.git fails with compiler bug for 2.081.1. It works fine with 2.080.0 I used dustmite to reduce it to: --- app.d template GenEvent(string eventName, T) { const char[] GenEvent = `private `~T.stringof~` _`~eventName~`;`~ T.stringof~eventName~`(`~T.stringof~` value) { import std.utf: toUTFz; import core.sys.windows.windows; _`~eventName~`= value; auto dlg = __traits(getOverloads, this, "`~eventName~`"); FARPROC fp = GetProcAddress(deltaLibrary.handle, "registerNotifyEvent"); Fn fn = cast(Fn) fp; fn(this.reference, pChar, cast(int) dlg.ptr, cast(int) dlg.funcptr, bindDelegate(dg)); } @property `~eventName~`() { return _`~`; }`; } auto bindDelegate() { } alias TNotifyEvent = void delegate(); class TBasicAction{ mixin(GenEvent!("OnExecute", TNotifyEvent)); } void main() { } --- Executing dmd app.d with 2.081.1 returns compiler bug. Executing it with 2.080.0 returns syntax errors which is expected as dustmite changed too much. But for analyzing the compiler bug, this should be fine.
Comment #1 by slavo5150 — 2018-08-10T00:36:38Z
Further reduced: alias TNotifyEvent = void delegate(); class TBasicAction { private TNotifyEvent _OnExecute; TNotifyEvent OnExecute(TNotifyEvent value) { auto dlg = __traits(getOverloads, this, "OnExecute"); } } Results in segmentation fault in traits.d
Comment #2 by slavo5150 — 2018-08-10T00:50:29Z
Further reduction to something that will compile successfully when the bug is fixed. class TBasicAction { int OnExecute() { auto name = __traits(getOverloads, this, "OnExecute").stringof; return 0; } } void main() {}
Comment #3 by slavo5150 — 2018-08-10T00:54:41Z
Comment #4 by github-bugzilla — 2018-08-14T14:41:37Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/9b637fc660c5f2e6610d0f967334f046eb4bdad7 Fix Issue 19152 - 2.081.1 Regression - Seg fault in traits.d https://github.com/dlang/dmd/commit/5445a8234ed3688f73dd137ab79ce68f54598326 Merge pull request #8553 from JinShil/fix_19152 Fix Issue 19152 - 2.081.1 Regression - Seg fault in traits.d
Comment #5 by slavo5150 — 2018-08-14T17:57:49Z
*** Issue 19170 has been marked as a duplicate of this issue. ***
Comment #6 by dlang-bot — 2021-01-03T22:57:18Z
dlang/dmd pull request #12093 "[dmd-cxx] Backport more recent traits to the C++ port" was merged into dmd-cxx: - 00a80d5e38f32cf4ff5b7fe8058c5be42067f286 by JinShil: [dmd-cxx] Fix Issue 19152 - 2.081.1 Regression - Seg fault in traits.c https://github.com/dlang/dmd/pull/12093