summaryrefslogtreecommitdiffstats
path: root/misc/cgo/testsanitizers/testdata/asan_global2_fail.go
blob: 19326333682f72a4be103119ff6c373228eda4b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2022 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.

package main

/*
#include <stdlib.h>
#include <stdio.h>

struct ss {
	int *p;
	int len;
	int cap;
};

int test(struct ss *a) {
	struct ss *t = a + 1;
	t->len = 100;          // BOOM
	return t->len;
}
*/
import "C"
import "fmt"

var tt C.struct_ss

func main() {
	r := C.test(&tt)
	fmt.Println("r value = ", r)
}