D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17738 - access to local alias from outside compiles but execution hangs
Summary: access to local alias from outside compiles but execution hangs
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-10 10:32 UTC by Dominikus Dittes Scherkl
Modified: 2024-12-13 18:53 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Dominikus Dittes Scherkl 2017-08-10 10:32:43 UTC
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
Comment 1 Dominikus Dittes Scherkl 2017-08-11 17:45:41 UTC
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.
Comment 2 dlangBugzillaToGithub 2024-12-13 18:53:55 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19298

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB