[Issue 12118] Modify immutable data using throw
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 16 17:02:26 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=12118
Nick Treleaven <nick at geany.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nick at geany.org
--- Comment #5 from Nick Treleaven <nick at geany.org> ---
comment #0:
> It is possible to throw an immutable Exception and catch it as mutable
Also, the exception is mutated when thrown so that is another safety violation
if immutable:
https://github.com/dlang/dmd/blob/v2.101.1/druntime/src/rt/deh.d#L13-L21
comment #3:
> At least, defining immutable constructor in derived classes of Throwable should be disallowed.
That wouldn't disallow:
throw new immutable Exception("");
--
More information about the Digitalmars-d-bugs
mailing list