www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23579] New: static locals cannot be initialized with stack

https://issues.dlang.org/show_bug.cgi?id=23579

          Issue ID: 23579
           Summary: static locals cannot be initialized with stack locals
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

The semantics of static locals should be changed to allow ttheir initialization
with stack locals or parameters. For example, the following example does not
compile

```
void v(int a)
{
    static int b = a;
}   
```

because

 test.d:3:20: Error: variable `a` cannot be read at compile time
but that should be accepted because it is equivalent to ``` void v(int a) { static int b; b = a; } ``` as `b` is only visible in `v` scope. --
Dec 25 2022