[Issue 2312] New: unexpected function addresses dump behaviour

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 25 05:29:32 PDT 2008


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

           Summary: unexpected function addresses dump behaviour
           Product: D
           Version: 1.034
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: enzo.petrelli at fastwebnet.it


/***************************
        OS:                                     Vista SP1
        Compiler/linker:        Digital Mars D Compiler v1.034
        Tango/tangobos Lib:     tango-0.99.7-bin-win32-dmd.1.033
        Compiled with:          no compile/link flag

        During a test session where the dump of function addresses was
required,
        an unexpected result was shown, as in the following simplified test
code.

        The expected result was to see three equal series of three different
addresses.

        It should also be noted that the requested padding with '0's for hex
values in
        writefln does not work for void*

 ***************************/

import std.cstream;

class DClass
{
        void func1()
        {
                return;
        }
        void func2()
        {
                return;
        }
        void func3()
        {
                return;
        }
}

void main()
{
        DClass oObj = new DClass;
        std.cstream.dout.writefln("      object: 0x%08X", cast(void*) &oObj);
        std.cstream.dout.writefln();

        // case 1:
        std.cstream.dout.writefln("object.func1: 0x%08X", cast(void*)
&oObj.func1);
        std.cstream.dout.writefln("object.func2: 0x%08X", cast(void*)
&oObj.func2);
        std.cstream.dout.writefln("object.func3: 0x%08X", cast(void*)
&oObj.func3);

        // case 2:
        alias void delegate()   DlgPtr;
        DlgPtr pDlg = &oObj.func1;
        std.cstream.dout.writefln("object.pfunc1:0x%08X", cast(void*) pDlg);
        pDlg = &oObj.func2;
        std.cstream.dout.writefln("object.pfunc2:0x%08X", cast(void*) pDlg);
        pDlg = &oObj.func3;
        std.cstream.dout.writefln("object.pfunc3:0x%08X", cast(void*) pDlg);

        // case 3:
        alias void function()   FncPtr;
        FncPtr pFnc = cast(FncPtr) &oObj.func1;
        std.cstream.dout.writefln("object.pfunc1:0x%08X", cast(void*) pFnc);
        pFnc = cast(FncPtr) &oObj.func2;
        std.cstream.dout.writefln("object.pfunc2:0x%08X", cast(void*) pFnc);
        pFnc = cast(FncPtr) &oObj.func3;
        std.cstream.dout.writefln("object.pfunc3:0x%08X", cast(void*) pFnc);
}

/*
output obtained:

      object: 0x  12FE38

object.func1: 0x 19D3FF0
object.func2: 0x 19D3FF0
object.func3: 0x 19D3FF0
object.pfunc1:0x 19D3FF0
object.pfunc2:0x 19D3FF0
object.pfunc3:0x 19D3FF0
object.pfunc1:0x  402010
object.pfunc2:0x  402018
object.pfunc3:0x  402020
*/


-- 



More information about the Digitalmars-d-bugs mailing list