Bug 14739 – Immutable alias to template triggers dmd assert

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-06-26T21:51:41Z
Last change time
2020-07-21T00:16:50Z
Keywords
ice, mangling
Assigned to
No Owner
Creator
joeyemmons
See also
https://issues.dlang.org/show_bug.cgi?id=15092

Comments

Comment #0 by joeyemmons — 2015-06-26T21:51:41Z
The following code when trying to compile triggers an assert in dmd. module main; void main(string[] args) { immutable int a; immutable int b; test!a ta; test!b tb; } struct test(alias a){} >dmd main.d Assertion failure: 'type->ty != Tstruct || ((TypeStruct *)type)->sym == this' on line 929 in file 'struct.c'
Comment #1 by joeyemmons — 2015-06-26T21:55:25Z
Should have said DMD32 D Compiler v2.067.1
Comment #2 by dlang-bugzilla — 2015-06-28T13:59:53Z
This program compiled in 2.062, and stopped compiling with an ICE after: https://github.com/D-Programming-Language/dmd/pull/1760 The ICE was fixed and the error changed to "failed semantic analysis" in 2.064, after: https://github.com/D-Programming-Language/dmd/pull/2645 The ICE was reintroduced in 2.066, after: https://github.com/D-Programming-Language/dmd/pull/3383
Comment #3 by k.hara.pg — 2015-07-04T05:28:01Z
(In reply to joeyemmons from comment #0) > Assertion failure: 'type->ty != Tstruct || ((TypeStruct *)type)->sym == > this' on line 929 in file 'struct.c' (In reply to Vladimir Panteleev from comment #2) > https://github.com/D-Programming-Language/dmd/pull/1760 > https://github.com/D-Programming-Language/dmd/pull/2645 > https://github.com/D-Programming-Language/dmd/pull/3383 The root issue is in the template mangling process. Currently typeof(ta) and typeof(tb) are angled to the same name S4main14__T4testVyii0Z4test, but I think it's wrong - the given argument `a` and `b` should be mangled differently on alias parameter. And the issue has existed from the previous of 2.062, the generated executable had silently corrupted. The added assertion is detecting the compiler internal structure issue correctly today. Downgrade to 'critical' issue.
Comment #4 by dfj1esp02 — 2015-10-21T12:17:40Z
--- void f() { int a, b; test!a ta; test!b tb; } struct test(alias a){} --- For some reason this compiles. Do instances have different mangled name here?
Comment #5 by ibuclaw — 2018-07-02T21:19:47Z
This seems to be fixed now, added the test case here to make sure it doesn't regress. https://github.com/dlang/dmd/pull/8428
Comment #6 by github-bugzilla — 2018-07-03T23:50:37Z
Commit pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/484c9db86973921f736e1632e646bef3d19b1df6 Fix Issue 14739 - Immutable alias to template triggers dmd assert
Comment #7 by dlang-bot — 2020-07-21T00:16:50Z
dlang/dmd pull request #11436 "[dmd-cxx] fix Issue 14739, 19024, 21060: ICE in semantic, at d/dmd/dstruct.c:1224" was merged into dmd-cxx: - 4a2df4271c098f07472ddd7f9933f673e017e9bc by Iain Buclaw: Fix Issue 14739 - Immutable alias to template triggers dmd assert https://github.com/dlang/dmd/pull/11436