New update fix

Salih Dincer salihdb at hotmail.com
Sat Mar 2 08:41:40 UTC 2024


SLM,

What exactly did this patch with the new update fix?
- https://dlang.org/changelog/2.107.0.html#bugfix-list
- https://issues.dlang.org/show_bug.cgi?id=16357

```d
   uint x = 255;
   auto data = cast(ubyte[])[x];

   assert(data[0] == 255);   // ok
   assert(data.length == 4); // error
```

Should it give an assertion error above with this update? Be open 
with wouldn't it be nice to be able to do a binary sum example 
without needing extra code?

```d

   enum p1 = 131071;
   enum p2 = 524287;

void main()
{
   import std.stdio;
   foreach(p; [p1, p2, p1 + p2])
   {
     write("[ ");
     //auto d = [p];
     foreach_reverse(b; cast(ubyte[])[p])
     {
       b.writef!"%08b ";
     }
     writeln("]");
   }
} /* Expected:
[ 00000000 00000001 11111111 11111111 ]
[ 00000000 00000111 11111111 11111111 ]
[ 00000000 00001001 11111111 11111110 ]
*/
```

SDB at 79


More information about the Digitalmars-d-learn mailing list