Bug 23710 – [REG master] Reachable code inside an 'if (false)' block no longer gets codegen
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-02-15T15:15:07Z
Last change time
2023-02-26T13:36:13Z
Keywords
pull
Assigned to
No Owner
Creator
Iain Buclaw
Comments
Comment #0 by ibuclaw — 2023-02-15T15:15:07Z
Consider the following:
---
int test(int i)
{
int[] foo;
if (0)
{
for (;;)
{
import core.stdc.stdio;
printf("start body\n");
foo = foo ~ [1,2,3];
L1:
printf("foo.length = %zu\n", foo.length);
i += 2;
if (i > 5)
return i;
printf("end body\n");
}
}
goto L1;
}
extern(C) int main() { return test(1); }
---
Actual run-time result:
---
foo.length = 0
end body
foo.length = 0
end body
foo.length = 0
---
Expected run-time result:
---
foo.length = 0
end body
start body
foo.length = 3
end body
start body
foo.length = 6
---
Also noting that when compiling with `-betterC`, there is no error about the use of RTTI in the array concat expression.