Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access to local alias from outside compiles but execution hangs #19298

Open
dlangBugzillaToGithub opened this issue Aug 10, 2017 · 1 comment
Labels

Comments

@dlangBugzillaToGithub
Copy link

Dominikus Dittes Scherkl reported this on 2017-08-10T10:32:43Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=17738

CC List

  • ZombineDev

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 fine
@dlangBugzillaToGithub
Copy link
Author

dominikus commented on 2017-08-11T17:45:41Z

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant