Bug 8608 – ICE(interpret.c): CTFE using runtime variable as ref parameter

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-09-02T11:36:00Z
Last change time
2015-06-09T05:10:43Z
Keywords
CTFE, ice, pull
Assigned to
nobody
Creator
eyyub.pangearaion

Comments

Comment #0 by eyyub.pangearaion — 2012-09-02T11:36:58Z
Hi, <code> import std.stdio; import std.datetime; import std.parallelism; void doFor(File file) { static uint n; ++n; file.writeln("Task n°", n, " begin: ", Clock.currAppTick); for(uint i = 0; i < 100; ++i) {} file.writeln("Task n°", n, " end : ", Clock.currAppTick); } void main() { writeln("begin"); auto file = File("task.txt", "w"); for(uint i = 0; i < 10; ++i) { auto test = task!(doFor(file)); test.executeInNewThread(); } file.close(); writeln("end"); } </code> That code produces this error : >Assertion failed: (v2->hasValue()), function interpret, file interpret.c, line 677. >Abort trap: 6 And, with dustmite, the result is : <code> import std.stdio; import std.parallelism; void doFor(File ) { } void main() { auto file = File; test = task!(doFor(file)); } </code> So, why is CTFE invoked here ?
Comment #1 by clugdbug — 2012-09-03T00:45:07Z
CTFE is invoked because doFor(file) is an expression, and therefore cannot be an alias. So that's not a bug. The internal compiler error obviously is, though. It needs to be reduced a bit further to see what's triggering it. Partly reduced test case: import std.stdio; void task(F)(F fun) {} void doFor(File ) { } void main() { File file; task!(doFor(file)); }
Comment #2 by eyyub.pangearaion — 2012-09-03T01:58:26Z
(In reply to comment #1) > CTFE is invoked because doFor(file) is an expression Oh indeed, I didn't notice that...sorry. >The internal compiler error obviously is, though. Yes, the error is strange. Thanks,
Comment #3 by clugdbug — 2012-09-10T01:03:22Z
Reduced test case shows it is related to postblit. ----------------- struct Bug8608{ this(this) {} } void func08(Bug8608 x) { } void task08(F)(F fun) {} void bug8608() { Bug8608 file; task08!(func08(file)); }
Comment #4 by clugdbug — 2012-09-20T00:07:25Z
Further reduced. Does not involve postblit, also applies to D1. -------- void bug8608(ref int m) {} void test8608() { int z; bool foo() { bug8608(z); return true; } static assert(foo()); }
Comment #5 by github-bugzilla — 2012-09-21T08:34:41Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/419ceeed0f56ad23fdd36216ab4763e0d9f148a3 Fix issue 8608 ICE(interpret.c): CTFE using runtime variable as ref parameter
Comment #6 by k.hara.pg — 2012-09-21T09:00:27Z
Comment #7 by github-bugzilla — 2012-09-23T15:41:48Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/016aacaf6b97644102e476106092673913431d68 merge D2 pull #1130 fix Issue 8608 - ICE(interpret.c): CTFE using runtime variable as ref parameter