www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

D - serious bug with bit variables

↑ ↓ ← "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
↑ ↓ → "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