Bug 7630 – declaration in switch scope not initialized + CTFE error
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-02T09:47:00Z
Last change time
2012-03-12T07:24:28Z
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2012-03-02T09:47:15Z
int foo(int a)
{
switch (a)
{
int res;
case 1:
res = 1;
return res;
case 2:
return res;
default:
return 0;
}
}
void main()
{
enum v1 = foo(1); // CTFE error, v->addrOnStack not set
enum v2 = foo(2); // CTFE error, used before initialization
assert(foo(2) == 0); // runtime error, res is uninitialized
}
--------
Comment #1 by code — 2012-03-12T07:24:28Z
*** This issue has been marked as a duplicate of issue 3820 ***