Skip to content

Instantly share code, notes, and snippets.

@mppf
Created June 20, 2017 14:19
Show Gist options
  • Save mppf/40edb05fdf275482c687983c5faa3398 to your computer and use it in GitHub Desktop.
Save mppf/40edb05fdf275482c687983c5faa3398 to your computer and use it in GitHub Desktop.
D lang array resize pointer safety example
/* compile with ldc2 a.d */
module a;
import std.stdio;
@safe
int main()
{
int[] array;
array.length = 7;
array[1] = 1;
auto myRef = &array[1];
array.length = 100000;
*myRef = 4;
writeln(array[1]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment