Issue 24872 - Assigning non-copyable value to array has no effect
Summary: Assigning non-copyable value to array has no effect
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
: 24433 (view as issue list)
Depends on:
Blocks:
 
Reported: 2024-11-22 18:42 UTC by Paul Backus
Modified: 2024-11-29 13:18 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Paul Backus 2024-11-22 18:42:38 UTC
As of DMD 2.109.1, the following program produces an assertion failure when run:

---
struct S
{
    int n;
    @disable this(this);
}

void main()
{
    import std.stdio;

    S[1] arr = [S(123)];
    arr = S(456);
    assert(arr[0].n == 456); // fail
}
---

The error message is

---
core.exception.AssertError@bug.d(13): 123 != 456
---

This shows that the new value of S(456) is not assigned to arr[0].
Comment 1 Dlang Bot 2024-11-22 19:05:57 UTC
@pbackus created dlang/dmd pull request #17083 "Fix Bugzilla 24872 - Assigning non-copyable value to array has no effect" fixing this issue:

- Fix Bugzilla 24872 - Assigning non-copyable value to array has no effect

https://github.com/dlang/dmd/pull/17083
Comment 2 Steven Schveighoffer 2024-11-22 19:48:42 UTC
*** Issue 24433 has been marked as a duplicate of this issue. ***
Comment 3 Dlang Bot 2024-11-22 21:51:08 UTC
dlang/dmd pull request #17083 "Fix Bugzilla 24872 - Assigning non-copyable value to array has no effect" was merged into stable:

- 36c2e531ab76e0c1099a3f9b293d255f82265c3f by Paul Backus:
  Fix Bugzilla 24872 - Assigning non-copyable value to array has no effect

https://github.com/dlang/dmd/pull/17083
Comment 4 Dlang Bot 2024-11-29 13:18:44 UTC
dlang/dmd pull request #17098 "Merge stable" was merged into master:

- 4c645bbaf970985f9d30e25a4b8f7bdd39b765ef by Paul Backus:
  Fix Bugzilla 24872 - Assigning non-copyable value to array has no effect

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