PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgo / misc / cgo / testsanitizers / src / msan2.go
blob6690cb034fcf36015f37787e8119c1976804fb28
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 #include <string.h>
9 #include <stdint.h>
10 #include <stdlib.h>
12 void f(int32_t *p, int n) {
13 int32_t * volatile q = (int32_t *)malloc(sizeof(int32_t) * n);
14 memcpy(p, q, n * sizeof(*p));
15 free(q);
18 void g(int32_t *p, int n) {
19 if (p[4] != 1) {
20 abort();
24 import "C"
26 import (
27 "unsafe"
30 func main() {
31 a := make([]int32, 10)
32 C.f((*C.int32_t)(unsafe.Pointer(&a[0])), C.int(len(a)))
33 a[4] = 1
34 C.g((*C.int32_t)(unsafe.Pointer(&a[0])), C.int(len(a)))