summaryrefslogtreecommitdiffstats
path: root/src/cmd/link/testdata/testRO
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/link/testdata/testRO')
-rw-r--r--src/cmd/link/testdata/testRO/x.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/cmd/link/testdata/testRO/x.go b/src/cmd/link/testdata/testRO/x.go
new file mode 100644
index 0000000..d77db6d
--- /dev/null
+++ b/src/cmd/link/testdata/testRO/x.go
@@ -0,0 +1,22 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that read-only data is indeed read-only. This
+// program attempts to modify read-only data, and it
+// should fail.
+
+package main
+
+import "unsafe"
+
+var s = "hello"
+
+func main() {
+ println(s)
+ *(*struct {
+ p *byte
+ l int
+ })(unsafe.Pointer(&s)).p = 'H'
+ println(s)
+}