www.digitalmars.com         C & C++   DMDScript  

D - DMD 0.61 Bug

reply "Dario" <supdar yahoo.com> writes:
The following code:
    class MyClass
    {
        uint myFunc()
        {
            uint myInt = 13;
            uint mySubFunc()
            {
                return myInt;
            }
            return mySubFunc();
        }
    }
    int main()
    {
        MyClass myInstance = new MyClass;
        printf("%i", myInstance.myFunc());
        return 0;
    }
Should print 13. It prints 4202543 instead. =)
If I move "uint myInt = 13;" from myFunc's to MyClass's scope it works
correctly.
I hope I haven't reported an already reported bug.
Apr 28 2003
next sibling parent Paul Runde <prunde consolidated.net> writes:
I was using printf's to try to see what was going on.

class MyClass
{
   uint myFunc()
   {
     uint myInt = 13;
     //printf("%d\n", myInt);
     uint mySubFunc()
     {
       printf("%d\n", myInt);
       return myInt;
     }
     //printf("%d\n", myInt);
     return mySubFunc();
   }
}


int main(char[][] args)
{
   MyClass myInstance = new MyClass;
   printf("%i", myInstance.myFunc());
   return 0;
}

Run this and it returns:
4202571
4202571

Uncomment one of the other printf's and I get:
13
13
13

What would cause that?


Dario wrote:
 The following code:
     class MyClass
     {
         uint myFunc()
         {
             uint myInt = 13;
             uint mySubFunc()
             {
                 return myInt;
             }
             return mySubFunc();
         }
     }
     int main()
     {
         MyClass myInstance = new MyClass;
         printf("%i", myInstance.myFunc());
         return 0;
     }
 Should print 13. It prints 4202543 instead. =)
 If I move "uint myInt = 13;" from myFunc's to MyClass's scope it works
 correctly.
 I hope I haven't reported an already reported bug.
 
 
Apr 28 2003
prev sibling next sibling parent Paul Runde <prunde consolidated.net> writes:
Try this:

class MyClass
{
   uint myFunc()
   {
     uint myInt = 13;
     uint mySubFunc()
     {
       printf("%d\n", *(&myInt + 2));
       printf("%d\n", myInt);
       return myInt;
     }
     return mySubFunc();
   }
}


int main(char[][] args)
{
   MyClass myInstance = new MyClass;
   printf("%i", myInstance.myFunc());
   return 0;
}

Prints:
13
4202599
4202599

The first line is whatever number I have initialized myInt with.

Dario wrote:
 The following code:
     class MyClass
     {
         uint myFunc()
         {
             uint myInt = 13;
             uint mySubFunc()
             {
                 return myInt;
             }
             return mySubFunc();
         }
     }
     int main()
     {
         MyClass myInstance = new MyClass;
         printf("%i", myInstance.myFunc());
         return 0;
     }
 Should print 13. It prints 4202543 instead. =)
 If I move "uint myInt = 13;" from myFunc's to MyClass's scope it works
 correctly.
 I hope I haven't reported an already reported bug.
 
 
Apr 28 2003
prev sibling parent "Walter" <walter digitalmars.com> writes:
Looks like a bug. I'll check it out. -Walter
May 01 2003