Is there a D equivalent of the C++ at method? I would like to reformulate

repro2.d
---
void main ()
{
   import std.stdio;
   import std.container;
   import std.range;
   auto z = Array!char();
   z.reserve(0xC000_0000);
   z.capacity.writeln;
   z.length.writeln;
   for (uint u = 0; u < 0xC000_0000; ++u)
      z.insert = 'Y';
   int i = -1073741825;
   i.writeln;
   z[i] = 'Q';
   z[i].writeln;
}
---

$ dmd -O -m32 repro2.d
$ ./repro2
3221225472
0
-1073741825
Q

such that it fails like the 64 bit version:

$ dmd -O -m64 repro2.d
$ ./repro2

3221225472
0
-1073741825
core.exception.RangeError@.../dmd2/linux/bin64/../../src/phobos/std/container/array.d(650):
 Range violation
----------------
??:? _d_arrayboundsp [0x440d22]
.../dmd2/linux/bin64/../../src/phobos/std/container/array.d:650 inout pure nothrow ref @nogc @safe inout(char) std.container.array.Array!(char).Array.opIndex(ulong) [0x43bb0f]
repro2.d:14 _Dmain [0x43afff]

Reply via email to