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/compile: error inlining function that uses unnamed struct with tagged fields #14331

Closed
alinz opened this issue Feb 15, 2016 · 8 comments
Closed
Milestone

Comments

@alinz
Copy link

alinz commented Feb 15, 2016

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

go1.6rc1 and go1.6rc2

What operating system and processor architecture are you using?

OSX El Capitan

What did you do?

I have started to see some wired compile issue in my project when I upgrade to 1.6. In order to make it more clear I have strip down my entire project and created a very small project which highlights the issues. The repo can be found here.

the wired part is that if fmt.Println("") added in Service function, it fixes the probelm.

What did you expect to see?
Just compile the code.

What did you see instead?

Line 6, file cmd/issue/main.go

cannot use issue.Conf.OAuth2Google (type struct { ClientID string "toml:\"client_id\""; 
ClientSecret string "toml:\"client_secret\""; RedirectURL string "toml:\"redirect_url\"" }) 
as type struct { ClientID string; ClientSecret string; RedirectURL string } in assignment
Line 11, file cmd/issue/main.go

internal compiler error: agen: unknown op CONV u(2) l(11) tc(1) implicit(true) 
STRUCT-struct { ClientID string; ClientSecret string; RedirectURL string }
@davecheney
Copy link
Contributor

Which versions of go does this code compile cleanly in?

On Mon, 15 Feb 2016, 15:12 Ali Najafizadeh notifications@github.com wrote:

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

go1.6rc1 and go1.6rc2

What operating system and processor architecture are you using?

OSX El Capitan

What did you do?

I have started to see some wired compile issue in my project when I
upgrade to 1.6. In order to make it more clear I have strip down my entire
project and created a very small project which highlights the issues. The
repo can be found here https://github.com/alinz/goissue.git.

the wired part is that if fmt.Println("") added in Service function, it
fixes the probelm.

What did you expect to see?
Just compile the code.

What did you see instead?

Line 6, file cmd/issue/main.go

cannot use issue.Conf.OAuth2Google (type struct { ClientID string "toml:"client_id"";
ClientSecret string "toml:"client_secret""; RedirectURL string "toml:"redirect_url"" })
as type struct { ClientID string; ClientSecret string; RedirectURL string } in assignment

Line 11, file cmd/issue/main.go

internal compiler error: agen: unknown op CONV u(2) l(11) tc(1) implicit(true)
STRUCT-struct { ClientID string; ClientSecret string; RedirectURL string }


Reply to this email directly or view it on GitHub
#14331.

@alinz
Copy link
Author

alinz commented Feb 15, 2016

@davecheney I compiles fine in 1.5.3.

@davecheney
Copy link
Contributor

This is a weird interaction with inlining. The call to "fmt" makes service.Service not a leaf function and thus unlinable so the defintion of service.Service is not written to the head of the .a file.

/cc @rsc @ianlancetaylor

@alinz
Copy link
Author

alinz commented Feb 15, 2016

@davecheney, One other interesting thing that I found is that instead of this

func Service() {
    conf := issue.Conf.OAuth2Google

    access := &Access{
        ClientID: conf.ClientID,
    }
}

if you set ClientID directly, it works and compiles fine

func Service() {
    access := &Access{
        ClientID: issue.Conf.OAuth2Google.ClientID,
    }
}

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Feb 16, 2016
@ianlancetaylor ianlancetaylor changed the title Code is not compile in go1.6rc1 and go1.6rc2 cmd/compile: error inlining function that uses unnamed struct with tagged fields Feb 16, 2016
@ianlancetaylor
Copy link
Contributor

This is a compiler bug in the handling of inlining functions with unnamed structs with tags. I wrote a simpler test case in https://golang.org/cl/19520.

I marked this 1.6, but this seems rare enough that I think it might be OK to postpone this to a future 1.6.1.

@gopherbot
Copy link

CL https://golang.org/cl/19520 mentions this issue.

@rsc
Copy link
Contributor

rsc commented Feb 16, 2016

I'll work on a CL to disable inlining in this case for Go 1.6. We can do a proper fix in Go 1.7.

@gopherbot
Copy link

CL https://golang.org/cl/19514 mentions this issue.

@golang golang locked and limited conversation to collaborators Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants