Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: regression in Go1.12beta2 causes "unexpected semicolon, expecting expression" error #30117

Closed
rjeczalik opened this issue Feb 7, 2019 · 6 comments

Comments

@rjeczalik
Copy link

commented Feb 7, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12beta2 darwin/amd64

Does this issue reproduce with the latest release?

No (tested go version go1.11.5 darwin/amd64).

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN="/Users/rjeczalik/bin"
GOCACHE="/Users/rjeczalik/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Volumes/rjk.io/work"
GOPROXY=""
GORACE=""
GOROOT="/Users/rjeczalik/go"
GOTMPDIR=""
GOTOOLDIR="/Users/rjeczalik/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dl/s7jq4vyn7358p1mtsmn3bk5w0000gn/T/go-build100527020=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

$ cat main.go
package main

// #include <CoreServices/CoreServices.h>
// typedef void (*CFRunLoopPerformCallBack)(void*);
// #cgo LDFLAGS: -framework CoreServices
import "C"

var eventloop = C.CFRunLoopSourceCreate(C.kCFAllocatorDefault, 0, &C.CFRunLoopSourceContext{
	perform: (C.CFRunLoopPerformCallBack)(nil),
})

func main() {}
go build

What did you expect to see?

What did you see instead?

# _/Users/rjeczalik/src/bug
./main.go:8:86: syntax error: unexpected semicolon, expecting expression

@odeke-em odeke-em changed the title cgo: no longer builds with go1.12beta2 cmd/cgo: regression in Go1.12beta2 causes "unexpected semicolon, expecting expression" error Feb 7, 2019

@odeke-em

This comment has been minimized.

Copy link
Member

commented Feb 7, 2019

Thank you for reporting this issue @rjeczalik!

I shall kindly page @ianlancetaylor.

@AlexRouSg

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2019

Lighter OS agnostic repo that I confirmed still happens on tip hash aa161ad

package main

/*
typedef void (*CFRunLoopPerformCallBack)(void*);

typedef struct {
	CFRunLoopPerformCallBack perform;
}CFRunLoopSourceContext;

#define kCFAllocatorDefault 1

int CFRunLoopSourceCreate(int a, int b, CFRunLoopSourceContext* c) {return 0;}
*/
import "C"

var eventloop = C.CFRunLoopSourceCreate(C.kCFAllocatorDefault, 0, &C.CFRunLoopSourceContext{
	perform: (C.CFRunLoopPerformCallBack)(nil),
})

func main() {}

Does not repo with only

var eventloop = &C.CFRunLoopSourceContext{
	perform: (C.CFRunLoopPerformCallBack)(nil),
}
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2019

@AlexRouSg The updated version does build for me, and this looks like the same problem as #29781, which is fixed on tip. Can you double check that you used the tip version of cgo? Thanks.

@AlexRouSg

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2019

@ianlancetaylor yup did a fresh git clone and build with hash 7ccd358

PS C:\Users\alexr\go\src\test> c:/Go-tip/bin/go.exe version
go version devel +7ccd3583ed Thu Feb 7 18:34:43 2019 +0000 windows/amd64
PS C:\Users\alexr\go\src\test> c:/Go-tip/bin/go.exe run .
# test
.\test.go:16:86: syntax error: unexpected semicolon, expecting expression

Not sure if it matters but I'm on windows amd64

@AlexRouSg

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2019

facepalm I forgot to set goroot

yup doesn't happen on tip

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Feb 8, 2019

Thanks for testing. I'm going to close this as fixed on tip. Thanks for reporting the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.