Thread overview
DMD 0.61 Bug
Apr 28, 2003
Dario
Apr 28, 2003
Paul Runde
Apr 28, 2003
Paul Runde
May 01, 2003
Walter
April 28, 2003
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.


April 28, 2003
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.
> 
> 

April 28, 2003
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.
> 
> 

May 01, 2003
Looks like a bug. I'll check it out. -Walter