[Issue 7335] sometimes the OUT - block have undefined class members-acces

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 24 14:32:44 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7335


Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com


--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> 2012-01-24 14:32:40 PST ---
A somewhat simplified example:
----------------------
import core.stdc.stdio;

class A {
  int mValue = 10;

  void setValue( int newValue)
    in
    { printf("A.setValue.in()\n");
    }       
    out
    { printf("A.setValue.Out(value = %d)\n", mValue);
    } 
    body
    { mValue = newValue;
    }
}



class B : A {
  override void setValue( int newValue)
   in
   { // not checked because super.IN-check will pass  
     printf("B.setValue.in()\n");
   }
   out
   { printf("B.setValue.Out(value = %d)\n", mValue);
   }
   body
   { mValue = newValue;
   }
}



class C : A {
  override void setValue( int newValue)
    in
    { // not checked because super.IN-check will pass  
      printf("C.setValue.in()\n");
      int a = newValue;   // The only difference to B
    }
    out
    { printf("C.setValue.Out(value = %d)\n", mValue);
    }
    body
    { mValue = newValue;
    }
}



void main() {
  printf("B:\n");
  A aObject = new B();
  aObject.setValue(3); 

  printf("\nC:\n");
  A bObject = new C(); 
  bObject.setValue(3);    // <<<<<  will crash because undefined mValue in the
                          // A.setValue().out-block.  
}
--------------------
The output is:
B:
A.setValue.in()
A.setValue.Out(value = 3)
B.setValue.Out(value = 3)

C:
A.setValue.in()
A.setValue.Out(value = 9772960)
C.setValue.Out(value = 3)
----------------------
I suspect the problem is the stack layout is not correct on the call to
A.setValue.in().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list