You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import std.traits;
foo.C foo(T, U)(const(T) a, const(U) b)
{
alias C = CommonType!(T, U);
return cast(C)a + cast(C)b;
}
// compiles, but execution hangs (programm uses 100% CPU and only ends after stack overflow is reached some time later)
CommonType!(T, U) foo2(T, U)(const(T) a, const(U) b)
{
alias C = CommonType!(T, U);
return cast(C)a + cast(C)b;
}
// compiles and runs fine
The text was updated successfully, but these errors were encountered:
Sorry, that was gdc, and it was the compilation that only stopped after stack overflow was reached (which took about 10 minutes).
dmd (2.075.0) directly fails with a segmentation fault (exit code 139).
(and of course it fails only, if foo is actually instantiated somewhere)
So, is it not allowed to access (type)definitions from outside the function where they are declared, or is this a real bug?
If it should not be allowed (which I would call a pitty), than a proper error message should be provided. Else I would expect foo and foo2 to compile to exactly the same assembly code.
Dominikus Dittes Scherkl reported this on 2017-08-10T10:32:43Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=17738
CC List
Description
import std.traits; foo.C foo(T, U)(const(T) a, const(U) b) { alias C = CommonType!(T, U); return cast(C)a + cast(C)b; } // compiles, but execution hangs (programm uses 100% CPU and only ends after stack overflow is reached some time later) CommonType!(T, U) foo2(T, U)(const(T) a, const(U) b) { alias C = CommonType!(T, U); return cast(C)a + cast(C)b; } // compiles and runs fineThe text was updated successfully, but these errors were encountered: