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/cover: compiler directives are not handled properly #17315

Closed
dhananjay92 opened this issue Oct 2, 2016 · 2 comments
Closed

cmd/cover: compiler directives are not handled properly #17315

dhananjay92 opened this issue Oct 2, 2016 · 2 comments

Comments

@dhananjay92
Copy link
Contributor

@dhananjay92 dhananjay92 commented Oct 2, 2016

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

go version go1.7.1 linux/amd64

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

GOARCH="amd64"
GOOS="linux"

What did you do?

Complete instruction on reproducing this error:

$ cat ~/tmp/haha.go 
package haha

import "hihi"

func init() {
    HahaImpl := haha
}

// Haha hihi hehe!
//
//go:noescape
func haha()

$ # Notice the misplaced compiler directive in the output below.
$ go tool cover -mode atomic -var Haha5678901234567890123 ~/tmp/haha.go
package haha

import _cover_atomic_ "sync/atomic"

import "hihi"

func init() {
    _cover_atomic_.AddUint32(&Haha5678901234567890123.

    //go:noescape
    Count[0], 1)
    HahaImpl := haha
}

func haha()

var _ = _cover_atomic_.AddUint32

var Haha5678901234567890123 = struct {
    Count     [1]uint32
    Pos       [3 * 1]uint32
    NumStmt   [1]uint16
} {
    Pos: [3 * 1]uint32{
        5, 7, 0x2000d, // [0]
    },
    NumStmt: [1]uint16{
        1, // 0
    },
}

What did you expect to see?

The compiler directive, //go:noescape, should not have been misplaced. It should have stayed with function declaration haha().

What did you see instead?

The compiler directive was misplaced.

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 2, 2016

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

@odeke-em odeke-em changed the title go cover doesn't handle compiler directives properly cmd/cover: compiler directives are not handled properly Oct 2, 2016
@odeke-em
Copy link
Member

@odeke-em odeke-em commented Oct 2, 2016

/cc @robpike

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.