D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8335 - `ref` is ignored for static array of stucts with postblit argument
Summary: `ref` is ignored for static array of stucts with postblit argument
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords: pull, wrong-code
Depends on:
Blocks:
 
Reported: 2012-07-02 03:39 UTC by Puneet Goel
Modified: 2012-07-22 15:44 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Puneet Goel 2012-07-02 03:39:35 UTC
I am testing with the latest pull from github and dmd ignoring "ref" when passing array as ref argument. Kindly see the code below. When I run this code it prints "Postblit called!" four time.

// 
struct Foo {
  this(this) {
    import std.stdio;
    writeln("Postblit called!");
  }
}

void barArray(ref Foo[4] _f) { /*do nothing*/ }

void main() {
  Foo [4] fooArray;
  barArray(fooArray);
}
Comment 1 Denis Shelomovskii 2012-07-02 04:03:40 UTC
Another testcase:
---
struct S
{
    int i;
    version(trigger_assert_in_main)
        // `@disable` will just be ignored
        // and postblit will not be called.
        // Looks like because of Issue 7579.
        @disable this(this);
    else
        this(this) { assert(0); }
}

void f(ref S[3] arr)
{
    arr[0].i = 7;
}

void main() {
    S[3] arr;
    f(arr);
    assert(arr[0].i == 7);
}
---
Comment 2 Kenji Hara 2012-07-02 08:58:44 UTC
This is definitely a bug, but is really *regression*?
I'd like to know the version of dmd which had worked correctly.
Comment 3 Kenji Hara 2012-07-02 09:27:18 UTC
(In reply to comment #2)
> This is definitely a bug, but is really *regression*?
> I'd like to know the version of dmd which had worked correctly.

Ah, OK. I found the reason of this bug, and this is a regression of 2.060head
(Does not occurs in 2.059).
Comment 5 github-bugzilla 2012-07-22 14:17:24 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/4ce0f83b388982f6fef550b5c4829acfe744e4f7
fix Issue 8335 - `ref` is ignored for static array of stucts with postblit argument

https://github.com/D-Programming-Language/dmd/commit/146442eb5d63c8ec88968122e2238cd607f2ecbb
Merge pull request #1035 from 9rnsr/fix8335

Issue 8335 - `ref` is ignored for static array of stucts with postblit argument