1
0
mirror of https://github.com/golang/go synced 2024-10-04 01:31:25 -06:00
go/misc/cgo/errors/malloc.go

24 lines
507 B
Go
Raw Normal View History

// Copyright 2016 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.
// Test that C.malloc does not return nil.
package main
// #include <stdlib.h>
import "C"
import (
"fmt"
)
func main() {
p := C.malloc(C.size_t(^uintptr(0)))
if p == nil {
fmt.Println("malloc: C.malloc returned nil")
// Just exit normally--the test script expects this
// program to crash, so exiting normally indicates failure.
}
}