PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgo / misc / cgo / testsanitizers / src / msan4.go
blob6c91ff5f091b6227e10ea76f5c7e04346b4dcd96
1 // Copyright 2015 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.
5 package main
7 // The memory profiler can call copy from a slice on the system stack,
8 // which msan used to think meant a reference to uninitialized memory.
11 #include <time.h>
12 #include <unistd.h>
14 extern void Nop(char*);
16 // Use weak as a hack to permit defining a function even though we use export.
17 void poison() __attribute__ ((weak));
19 // Poison the stack.
20 void poison() {
21 char a[1024];
22 Nop(&a[0]);
26 import "C"
28 import (
29 "runtime"
32 func main() {
33 runtime.MemProfileRate = 1
34 start(100)
37 func start(i int) {
38 if i == 0 {
39 return
41 C.poison()
42 // Tie up a thread.
43 // We won't actually wait for this sleep to complete.
44 go func() { C.sleep(1) }()
45 start(i - 1)
48 //export Nop
49 func Nop(*C.char) {