D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 23436 - Spec falsely states mutable references in struct .init are forbidden
Summary: Spec falsely states mutable references in struct .init are forbidden
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2022-10-25 17:23 UTC by Paul Backus
Modified: 2022-10-26 06:36 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Paul Backus 2022-10-25 17:23:13 UTC
The section of the language spec on default struct initialization [1] contains the following statement:

> The default initializers may not contain references to mutable data.

However, this statement is false. References to mutable data are allowed in default initializers of struct fields, and have been since at least DMD 2.060 (the oldest compiler available on run.dlang.io).

[1] https://dlang.org/spec/struct.html#default_struct_init
Comment 1 Dlang Bot 2022-10-25 17:26:00 UTC
@pbackus created dlang/dlang.org pull request #3447 "Fix 23436 - Spec falsely states mutable references in struct .init ar…" fixing this issue:

- Fix 23436 - Spec falsely states mutable references in struct .init are forbidden

https://github.com/dlang/dlang.org/pull/3447
Comment 2 Dlang Bot 2022-10-26 06:36:01 UTC
dlang/dlang.org pull request #3447 "Fix 23436 - Spec falsely states mutable references in struct .init ar…" was merged into master:

- 4a0af0866a28d7f196406d9266971ea93e45ff61 by Paul Backus:
  Fix 23436 - Spec falsely states mutable references in struct .init are forbidden

https://github.com/dlang/dlang.org/pull/3447