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); }
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); } ---
This is definitely a bug, but is really *regression*? I'd like to know the version of dmd which had worked correctly.
(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).
https://github.com/D-Programming-Language/dmd/pull/1035
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