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.
Comment #1 by ibuclaw — 2023-02-15T15:16:05Z
Comment #2 by dlang-bot — 2023-02-26T05:39:18Z
@WalterBright created dlang/dmd pull request #14916 "fix Issue 23710 - [REG master] Reachable code inside an 'if (false)' …" fixing this issue: - fix Issue 23710 - [REG master] Reachable code inside an 'if (false)' block no longer gets codegen https://github.com/dlang/dmd/pull/14916
Comment #3 by dlang-bot — 2023-02-26T13:36:13Z
dlang/dmd pull request #14916 "fix Issue 23710 - [REG master] Reachable code inside an 'if (false)' …" was merged into master: - 666dda60a56fa831d0bdf3db61845ea2a573d6dd by Walter Bright: fix Issue 23710 - [REG master] Reachable code inside an 'if (false)' block no longer gets codegen https://github.com/dlang/dmd/pull/14916