Bug 16244 – compiler ICE on complex `typeof()` for method arg type

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-07-06T20:15:00Z
Last change time
2017-08-07T13:16:26Z
Assigned to
nobody
Creator
ketmar

Comments

Comment #0 by ketmar — 2016-07-06T20:15:38Z
this code segfaults with 2.071: struct Foo { int get_val () const { return 0; } auto val() (typeof(cast()get_val) v) {} } void main () { Foo().val = 45; } note that removing `cast()` gives proper error message instead.
Comment #1 by ketmar — 2016-07-06T20:16:07Z
p.s. i.e. compiler segfaults, not the compiled code. sorry.
Comment #2 by ketmar — 2016-07-08T19:35:26Z
fix: diff --git a/src/dtemplate.d b/src/dtemplate.d index a5ca897..257ba2a 100644 --- a/src/dtemplate.d +++ b/src/dtemplate.d @@ -4883,7 +4883,7 @@ extern (C++) bool reliesOnTident(Type t, TemplateParameters* tparams = null, siz { //printf("CallExp::reliesOnTident('%s')\n", e.toChars()); visit(cast(UnaExp)e); - if (!result) + if (!result && e.to) // e.to can be null for `cast()` e.to.accept(this); } . --. 2.9.0
Comment #3 by bitter.taste — 2017-01-16T21:03:22Z
Comment #4 by github-bugzilla — 2017-06-14T06:37:34Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/0a2156bab6608efe8bc7d0efadc815bf2e322a9a Fix issue 16244 - Prevent an ICE with empty cast https://github.com/dlang/dmd/commit/e797f7e9bacc8324fd3a4d86913df7c73be4c7eb Merge pull request #6457 from LemonBoy/b16244 Fix issue 16244 - Prevent an ICE with empty cast
Comment #5 by github-bugzilla — 2017-08-07T13:16:26Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/0a2156bab6608efe8bc7d0efadc815bf2e322a9a Fix issue 16244 - Prevent an ICE with empty cast https://github.com/dlang/dmd/commit/e797f7e9bacc8324fd3a4d86913df7c73be4c7eb Merge pull request #6457 from LemonBoy/b16244