D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10123 - Can't subtract positive number from length of array of struct with disabled default construction
Summary: Can't subtract positive number from length of array of struct with disabled d...
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on: 10124
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-20 04:38 UTC by Denis Shelomovskii
Modified: 2022-11-29 13:30 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 Denis Shelomovskii 2013-05-20 04:38:29 UTC
---
struct S
{ @disable this(); }

void main()
{
    S[] arr = [S.init, S.init, S.init];
    --arr.length; // Error: struct main.S default construction is disabled
    arr.length -= 1; // Same error
    size_t n = 1;
    arr.length -= n; // Same error
}
---
Comment 1 Denis Shelomovskii 2013-05-20 04:53:15 UTC
Looks like Issue 10124 have to be fixed first.
Comment 2 basile-z 2019-03-30 12:12:56 UTC
I don't think this is a valid issue. When an array is shrink, its memory might be copied to another location. a struct with self reference would then become unsafe.

You cannot speculate on the implementation details of the GC allocator.