[Issue 7336] New: Sometimes OUT-Block dont have correct acces to	method-parameter
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sat Jan 21 10:02:10 PST 2012
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=7336
           Summary: Sometimes OUT-Block dont have correct acces to
                    method-parameter
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: devbai at mnet-mail.de
--- Comment #0 from Devbai <devbai at mnet-mail.de> 2012-01-21 10:02:07 PST ---
Hello,
It's possible, that a method-OUT-block dont, have access
tho the correct value of its method-parameter
this Programm:
**************
import std.stdio;
class ClassA 
{
  private int mValue=0;
  @property
  {  
    public int value() const 
    { return mValue;
    }
    public void value(int newValue)
    in
    { int dummy = newValue; // senseless use from newValue
    }
    out 
    { int a = newValue;
      writeln("checking OUT ClassA. at property value (mValue == newValue: ",
              mValue,  " == " , newValue, ")");
      assert(mValue==newValue); // <= assert will pass; 
                                // because the use newValue in the in-block
      writeln("  ... passed");
    } 
    body
    { mValue = newValue;
    }
  }
}
class ClassB
{
  private int mValue=0;
  @property
  {  
    public int value() const 
    { return mValue;
    }
    public void value(int newValue)
    out
    { int a = newValue;
      writeln("checking OUT ClassB. at property value (mValue == newValue: ",
               mValue,  " == " , newValue, ")");
      assert(mValue==newValue); // <= assert will (mostly) not pass;
                                // because newValue has here an undedined
                                // value but shoud be defined! 
      writeln("  ... passed");
    } 
    body
    { mValue = newValue;
    }
  }
}
public static void main ()
{
  writeln("***  START  ***");
  writeln("\nClassA:");
  ClassA aObject = new ClassA();
  aObject.value = 12;
  writeln("\nClassB:");
  ClassB bObject = new ClassB();
  bObject.value = 12;
  writeln("\n***  END  ***");
}
**************
compiled with DMD64 D Compiler v2.057
wil after running show following output:
**************
core.exception.AssertError at TestAppBugNoParamaterInOutBlock(46): Assertion
failure
----------------
./(_d_assertm+0x2a) [0x44830a]
./() [0x4450c2]
./(@property void TestAppBugNoParamaterInOutBlock.ClassB.value(int).void
__ensure()+0x58) [0x444fc0]
./(@property void TestAppBugNoParamaterInOutBlock.ClassB.value(int)+0x26)
[0x444f66]
./(_Dmain+0x7f) [0x445057]
./(extern (C) int rt.dmain2.main(int, char**).void runMain()+0x17) [0x44893f]
./(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void
delegate())+0x2a) [0x4484e6]
./(extern (C) int rt.dmain2.main(int, char**).void runAll()+0x42) [0x448992]
./(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void
delegate())+0x2a) [0x4484e6]
./(main+0xd3) [0x448477]
/lib/libc.so.6(__libc_start_main+0xfe) [0x7f72f9f71d8e]
----------------
***  START  ***
ClassA:
checking OUT ClassA. at property value (mValue == newValue: 12 == 12)
  ... passed
ClassB:
checking OUT ClassB. at property value (mValue == newValue: 12 == -772278112)
**************
the access in the IN-Block have influence to the correct/incorrect behavore
of the OUT-Block.
-- 
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