aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorvegecode <39607947+vegecode@users.noreply.github.com>2019-01-04 16:34:21 -0600
committerAndrew Kelley <andrew@ziglang.org>2019-01-04 17:34:21 -0500
commit1f08be4d7fdf08bda66312ab4b2e401de378083e (patch)
tree0bc6e3afdacd0b75f1870b5b953dd7a9722cf9c2 /test
parent5c2a1055a03d4ef9e4d292afe8b934cb6a7afa11 (diff)
downloadzig-1f08be4d7fdf08bda66312ab4b2e401de378083e.tar.gz
zig-1f08be4d7fdf08bda66312ab4b2e401de378083e.zip
Mark comptime int hardcoded address pointee as a run time variable #1171 (#1868)
* Mark comptime int hardcoded address as a run time variable #1171 * test case for dereferencing hardcoded address intToPtr
Diffstat (limited to 'test')
-rw-r--r--test/cases/inttoptr.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/cases/inttoptr.zig b/test/cases/inttoptr.zig
index 6695352383..ba3cc52f09 100644
--- a/test/cases/inttoptr.zig
+++ b/test/cases/inttoptr.zig
@@ -11,3 +11,17 @@ fn randomAddressToFunction() void {
var addr: usize = 0xdeadbeef;
var ptr = @intToPtr(fn () void, addr);
}
+
+test "mutate through ptr initialized with constant intToPtr value" {
+ forceCompilerAnalyzeBranchHardCodedPtrDereference(false);
+}
+
+fn forceCompilerAnalyzeBranchHardCodedPtrDereference(x: bool) void {
+ const hardCodedP = @intToPtr(*volatile u8, 0xdeadbeef);
+ if (x) {
+ hardCodedP.* = hardCodedP.* | 10;
+ } else {
+ return;
+ }
+}
+