[Issue 23710] New: [REG master] Reachable code inside an 'if (false)' block no longer gets codegen
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 15 15:15:07 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23710
Issue ID: 23710
Summary: [REG master] Reachable code inside an 'if (false)'
block no longer gets codegen
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ibuclaw at gdcproject.org
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.
--
More information about the Digitalmars-d-bugs
mailing list