Debian Codegraph @

src/cmd/link/testdata/testRO/x.go

raw
1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Test that read-only data is indeed read-only. This
6 // program attempts to modify read-only data, and it
7 // should fail.
8
9 package main
10
11 import "unsafe"
12
13 var s = "hello"
14
15 func main() {
16 println(s)
17 *(*struct {
18 p *byte
19 l int
20 })(unsafe.Pointer(&s)).p = 'H'
21 println(s)
22 }