Bug 8335 – `ref` is ignored for static array of stucts with postblit argument
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-02T03:39:00Z
Last change time
2012-07-22T15:44:00Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
puneet
Comments
Comment #0 by puneet — 2012-07-02T03:39:35Z
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 by verylonglogin.reg — 2012-07-02T04:03:40Z
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 by k.hara.pg — 2012-07-02T08:58:44Z
This is definitely a bug, but is really *regression*?
I'd like to know the version of dmd which had worked correctly.
Comment #3 by k.hara.pg — 2012-07-02T09:27:18Z
(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).