Created
April 2, 2018 21:20
-
-
Save run-dlang/a5db40e8ad377bda7aa49e2c1cf47391 to your computer and use it in GitHub Desktop.
Code shared from run.dlang.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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