Bug 17738 – access to local alias from outside compiles but execution hangs

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-08-10T10:32:43Z
Last change time
2024-12-13T18:53:55Z
Assigned to
No Owner
Creator
Dominikus Dittes Scherkl
Moved to GitHub: dmd#19298 →

Comments

Comment #0 by dominikus — 2017-08-10T10:32:43Z
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 by dominikus — 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.
Comment #2 by robert.schadek — 2024-12-13T18:53:55Z
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