PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgo / misc / cgo / testsanitizers / src / msan2_cmsan.go
blob8fdaea90c979245db3eb6221be76d77ac9fdf499
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 /*
8 #cgo LDFLAGS: -fsanitize=memory
9 #cgo CPPFLAGS: -fsanitize=memory
11 #include <string.h>
12 #include <stdint.h>
13 #include <stdlib.h>
15 void f(int32_t *p, int n) {
16 int32_t * volatile q = (int32_t *)malloc(sizeof(int32_t) * n);
17 memcpy(p, q, n * sizeof(*p));
18 free(q);
21 void g(int32_t *p, int n) {
22 if (p[4] != 1) {
23 abort();
27 import "C"
29 import (
30 "unsafe"
33 func main() {
34 a := make([]int32, 10)
35 C.f((*C.int32_t)(unsafe.Pointer(&a[0])), C.int(len(a)))
36 a[4] = 1
37 C.g((*C.int32_t)(unsafe.Pointer(&a[0])), C.int(len(a)))