Bug 10084 – alias template parameter and frame pointer capture problem
Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-14T12:36:30Z
Last change time
2024-03-19T10:12:38Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Øivind
Comments
Comment #0 by oivind.loe — 2013-05-14T12:36:30Z
The following code gives ICE: "Internal error: toir.c 183".
----------------------------------
void staticIterStructMembers(Type, alias Func)() {
void IterStructMemberCall(Member )() {
Func!Member;
}
IterStructMemberCall!Type;
}
template annotStruct() {
void save() {
void saveImpl(Member )() {
}
staticIterStructMembers!(typeof(this), saveImpl);
}
}
struct MsgBossCreateProc {
mixin annotStruct;
}
------------------------------------------------
This fails on master, e.g. what is about to be release 2.063:
commit 61bcb35cc9a0dd6377b5c17e07a1ea6cb7fb2f12
Merge: 4ed3396 1de9770
Author: Daniel Murphy <[email protected]>
Date: Tue May 14 01:07:59 2013 -0700
Comment #1 by k.hara.pg — 2013-05-14T20:53:05Z
What version did not cause ICE? I tested the code witn 2.057 to 2,062, and all had caused ICE.
If there was no version which was correctly working for the code, this issue should not be marked as a regression.
Comment #2 by oivind.loe — 2013-05-14T23:30:45Z
My bad. Went a bit quickly yesterday. Changed it from regression to 'major'.
Comment #3 by clugdbug — 2013-06-14T04:56:54Z
Probably a duplicate of one of the other ICE(toir.c) bugs. bug4504, bug5902, bug6426, bug8436 etc.
Comment #4 by k.hara.pg — 2013-11-16T04:38:18Z
Make the OP code more readable.
void callFunc(T, alias func)() {
void call(Member)() {
func!Member();
}
call!T;
}
template Mix() {
void save() {
void saveImpl(Member)() {
}
callFunc!(typeof(this), saveImpl);
}
}
struct S {
mixin Mix;
}
With 2.064, the code doesn't occur ICE. Instead following errors printed:
test.d(3): Error: function test.callFunc!(S, saveImpl).callFunc.call!(S).call cannot access frame of function test.S.Mix!().save
test.d(5): Error: template instance test.callFunc!(S, saveImpl).callFunc.call!(S) error instantiating
test.d(12): instantiated from here: callFunc!(S, saveImpl)
test.d(12): Error: template instance test.callFunc!(S, saveImpl) error instantiating
However compiler should accept the code. All of template functions instantiated in save() -
callFunc!(S, saveImpl),
callFunc!(S, saveImpl).call!T == callFunc!(S, saveImpl).call!Member
callFunc!(S, saveImpl).call!T.func!Member == save.saveImpl!Member
should capture the frame pointer of save() member function.
https://github.com/D-Programming-Language/dmd/pull/2780
Comment #5 by dfj1esp02 — 2024-03-19T10:12:38Z
*** This issue has been marked as a duplicate of issue 5710 ***