Bug 24460 – scope(failure) with a goto breaks safety

Status
NEW
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-03-27T17:10:19Z
Last change time
2024-12-13T19:34:11Z
Keywords
accepts-invalid, safe
Assigned to
No Owner
Creator
elpenguino+D
See also
https://issues.dlang.org/show_bug.cgi?id=21443, https://issues.dlang.org/show_bug.cgi?id=24462, https://issues.dlang.org/show_bug.cgi?id=24463
Moved to GitHub: dmd#20427 →

Comments

Comment #0 by elpenguino+D — 2024-03-27T17:10:19Z
``` void main() @safe { { scope(failure) goto ok; assert(0); } ok: } ``` Same rationale as https://issues.dlang.org/show_bug.cgi?id=21443
Comment #1 by razvan.nitu1305 — 2024-03-28T14:29:50Z
This doesn't seem like a safety violation. Rather that the scope failure should not catch the assert error.
Comment #2 by razvan.nitu1305 — 2024-03-28T14:37:35Z
Scratch that. The problem is that you are not rethrowing the exception/error if you use a goto.
Comment #3 by qs.il.paperinik — 2024-07-23T14:27:04Z
It seems `scope(failure) Fix; After;` lowers to ```d try { After; } catch(Throwable __o40) { Fix; throw; } ``` But it should lower to: ```d try { After; } catch(Throwable __th) { scope(exit) throw __th; Fix; } ``` `scope(failure)` is not supposed to be able to swallow the thrown object.
Comment #4 by robert.schadek — 2024-12-13T19:34:11Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20427 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB