D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20606 - Cannot cast non-mutable BitArray to void[], size_t[]
Summary: Cannot cast non-mutable BitArray to void[], size_t[]
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 minor
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-02-25 01:29 UTC by moonlightsentinel
Modified: 2020-02-25 07:01 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 moonlightsentinel 2020-02-25 01:29:26 UTC
BitArray's opCast does not work with const/immutable instances:

import std.bitmanip : BitArray;

void main() {
    BitArray m;
    const numbers = cast(size_t[]) m;
    const bytess = cast(void[]) m;
    
    // The following casts don't compile
    const BitArray c;
    const numbers = cast(const size_t[]) c;
    const bytess = cast(const void[]) c;
    
    immutable BitArray i;
    const numbers = cast(const size_t[]) i;
    const bytess = cast(const void[]) i;
}
Comment 1 Dlang Bot 2020-02-25 01:33:16 UTC
@MoonlightSentinel created dlang/phobos pull request #7405 "Fix Issue 20606 - Cannot cast non-mutable BitArray to void[], size_t[]" fixing this issue:

- Fix Issue 20606 - Cannot cast non-mutable BitArray to void[], size_t[]

https://github.com/dlang/phobos/pull/7405
Comment 2 Dlang Bot 2020-02-25 07:01:36 UTC
dlang/phobos pull request #7405 "Fix Issue 20606 - Cannot cast non-mutable BitArray to void[], size_t[]" was merged into master:

- 661eefd1a258f4f4c2f1821e70d645fe8ed1e4b3 by MoonlightSentinel:
  Fix Issue 20606 - Cannot cast non-mutable BitArray to void[], size_t[]

https://github.com/dlang/phobos/pull/7405