Skip to content

Instantly share code, notes, and snippets.

@run-dlang
Created April 2, 2018 21:20
Show Gist options
  • Save run-dlang/a5db40e8ad377bda7aa49e2c1cf47391 to your computer and use it in GitHub Desktop.
Save run-dlang/a5db40e8ad377bda7aa49e2c1cf47391 to your computer and use it in GitHub Desktop.
Code shared from run.dlang.io
int[] sneaky;
struct A
{
private int[] innocent;
~this()
{
sneaky = innocent;
}
}
void main()
{
immutable a = A([1, 2, 3]);
{
auto b = a;
}
sneaky[1] = 42; // oops
import std.stdio;
writeln(a.innocent); // ooooops
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment