www.digitalmars.com         C & C++   DMDScript  

D - serious bug with bit variables

reply "Pavel Minayev" <evilone omen.ru> writes:
Compile and run the following program. Look at the
output.

    import stdio;

    class bits
    {
     bit a = true, b = true, c = true;
     void dump()
     {
      printf("%d %d %d\n",
       cast(int)(a == true),
       cast(int)(b == true),
       cast(int)(c == true));
     }
    }

    int main(char[][] args)
    {
     bits k = new bits;
     k.a = true; k.dump();
     k.b = true; k.dump();
     k.c = true; k.dump();
     return 0;
    }

Program had displayed:

    1 0 0
    0 1 0
    0 0 1

No comments...
Dec 20 2001
parent "Walter" <walter digitalmars.com> writes:
That was caused by some confusion in the code generator as to whether a
standalone bit was one byte or 4. A fix will go out with the next
version. -Walter

"Pavel Minayev" <evilone omen.ru> wrote in message
news:9vtg4r$1p3p$1 digitaldaemon.com...
 Compile and run the following program. Look at the
 output.

     import stdio;

     class bits
     {
      bit a = true, b = true, c = true;
      void dump()
      {
       printf("%d %d %d\n",
        cast(int)(a == true),
        cast(int)(b == true),
        cast(int)(c == true));
      }
     }

     int main(char[][] args)
     {
      bits k = new bits;
      k.a = true; k.dump();
      k.b = true; k.dump();
      k.c = true; k.dump();
      return 0;
     }

 Program had displayed:

     1 0 0
     0 1 0
     0 0 1

 No comments...
Dec 20 2001