Kenji Hara <> changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Kenji Hara <> 2012-06-20 21:02:37 PDT ---
This is an expected behavior of attribute inference with inheritance.

class A {
    void foo() @trusted {}
class B : A {
    override void foo() {
        int n;
        //auto p = cast(int*)n;  // not allowed in safe code
void main() {
    pragma(msg, typeof(; // prints "@trusted void()"
    pragma(msg, typeof(; // prints "@safe void()" !

When you inherit a @trusted method, the derived method that you write is
inferred as @safe.
In other words, if you want to write @trusted code, you should qualify the
method with @trueted attribute.

class B : A {
    override void foo() @trusted {
        int n;
        auto p = cast(int*)n;  // allowed in trusted code

It seems to me that is necessary to avoid accidentally breaking of @safe

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to