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