Issue 4211 - struct with annotation(@safe)
Summary: struct with annotation(@safe)
Status: RESOLVED DUPLICATE of issue 5110
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-20 05:47 UTC by SHOO
Modified: 2014-02-15 02:43 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 SHOO 2010-05-20 05:47:44 UTC
@safe struct X
{
	void func() {  }
}

@safe class Y
{
	void func() {  }
}

@safe void main()
{
	X x;
	x.func(); // NG
	auto y = new Y;
	y.func(); // OK
}

Is this a bug?

I like the behavior of class.
I think that struct/union should change the behavior.
Comment 1 bearophile_hugs 2010-05-20 09:24:06 UTC
It's a bug.

This works:


struct Foo {
    @safe void func() {  }
}
@safe void main() {
    Foo f;
    f.func();
}
Comment 2 Walter Bright 2010-12-05 13:03:18 UTC

*** This issue has been marked as a duplicate of issue 5110 ***