Bug 24174 – [CTFE] goto within with statements & catch blocks cause a infinite loop
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-10-04T22:25:14Z
Last change time
2023-10-05T07:28:57Z
Keywords
pull
Assigned to
No Owner
Creator
Mai Lapyst
Comments
Comment #0 by info — 2023-10-04T22:25:14Z
Found a severe bug inside the CTFE engine, that completly stalls the compiler when two local gotos are used inside a with-statement or catch blocks:
---
bool func1() {
struct BtMatcher {
uint pc = 0;
}
BtMatcher matcher;
with (matcher) {
goto StartLoop;
StartLoop:
goto SecondLabel;
SecondLabel:
return true;
}
}
bool func2() {
try {
throw new Exception("a");
return true;
} catch (Exception e) {
goto StartA;
StartA:
goto StartB;
StartB:
return false;
}
}
// Either of these will put dmd into a endless loop
pragma(msg, func1());
pragma(msg, func2());
void main() {}
---
Comment #1 by dlang-bot — 2023-10-04T22:34:28Z
@Mai-Lapyst created dlang/dmd pull request #15651 "Fix issue 24174 - [CTFE] goto within with statements & catch blocks cause a infinite loop" fixing this issue:
- Fix issue 24174 - [CTFE] goto within with statements & catch blocks cause a infinite loop
https://github.com/dlang/dmd/pull/15651
Comment #2 by dlang-bot — 2023-10-05T07:28:57Z
dlang/dmd pull request #15651 "Fix issue 24174 - [CTFE] goto within with statements & catch blocks cause a infinite loop" was merged into master:
- 62c233919c06e4d2aa79449f83b1bd52d84b0a11 by Mai-Lapyst:
Fix issue 24174 - [CTFE] goto within with statements & catch blocks cause a infinite loop
https://github.com/dlang/dmd/pull/15651