www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7336] New: Sometimes OUT-Block dont have correct acces to method-parameter

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: devbai mnet-mail.de



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. 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. 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 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. property value (mValue == newValue: 12 == 12)
  ... passed

ClassB:
checking OUT ClassB. 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: -------
Jan 21 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7336


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |DUPLICATE



21:46:28 PST ---
Same fix as for 7335.

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

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