[Issue 22031] crt_constructor functions can't initialize immutable/const variables

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 3 18:31:11 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22031

Dlang Bot <dlang-bot at dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #1 from Dlang Bot <dlang-bot at dlang.rocks> ---
@MoonlightSentinel created dlang/dmd pull request #13751 "Fix 22031 - Allow
modification of non-mutable in `crt_[con|de]structor`'s" fixing this issue:

- Fix 22031 - Allow modification of non-mutable in `crt_[con|de]structor`'s

  Allow functions marked as `pragma(crt_[con|de]structor)` to modify
  `const` / `immutable` variables, which is currently restricted to
  module ctors / dtors. This enables the use of lazily initialized global
  constants for applications without druntime.

  Such function may not be called at runtime because they might violate
  the guarantees of `const` / `immutable`. Hence it is now an error to
  call a function marked as `pragma(crt_[con|de]structor)`.

https://github.com/dlang/dmd/pull/13751

--


More information about the Digitalmars-d-bugs mailing list