<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<ol dir="auto">
<li>
<p dir="auto">What version of Go are you using (<code class="notranslate">go version</code>)?<br>
<code class="notranslate">go version go1.6 linux/amd64</code></p>
</li>
<li>
<p dir="auto">What operating system and processor architecture are you using (<code class="notranslate">go env</code>)?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GOARCH=&quot;amd64&quot;
GOHOSTARCH=&quot;amd64&quot;
GOHOSTOS=&quot;linux&quot;
GOOS=&quot;linux&quot;
GORACE=&quot;&quot;
GO15VENDOREXPERIMENT=&quot;1&quot;
CC=&quot;gcc&quot;
GOGCCFLAGS=&quot;-fPIC -m64 -pthread -fmessage-length=0&quot;
CXX=&quot;g++&quot;
CGO_ENABLED=&quot;1&quot;"><pre class="notranslate"><code class="notranslate">GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GORACE=""
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
</code></pre></div>
</li>
<li>
<p dir="auto">What did you do?<br>
When the <code class="notranslate">go test</code> command, with the <code class="notranslate">-coverprofile</code> flag, needs to compile a source file, it reports errors using an incorrect line number.</p>
<p dir="auto">The problem can be reproduced running<br>
<code class="notranslate">$go test -coverprofile=/tmp/out</code><br>
with this source file:<br>
<a href="https://play.golang.org/p/WAB6gv-0HC" rel="nofollow">https://play.golang.org/p/WAB6gv-0HC</a><br>
and test file:<br>
<a href="https://play.golang.org/p/LCkNJTTOQ1" rel="nofollow">https://play.golang.org/p/LCkNJTTOQ1</a></p>
</li>
<li>
<p dir="auto">What did you expect to see?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# test/bug01
/tmp/go-build602734163/test/bug01/_test/_obj_test/bug.go:6: undefined: fmt.Printz
FAIL    test/bug01 [build failed]"><pre class="notranslate"><code class="notranslate"># test/bug01
/tmp/go-build602734163/test/bug01/_test/_obj_test/bug.go:6: undefined: fmt.Printz
FAIL    test/bug01 [build failed]
</code></pre></div>
</li>
<li>
<p dir="auto">What did you see instead?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# test/bug01
/tmp/go-build602734163/test/bug01/_test/_obj_test/bug.go:7: undefined: fmt.Printz
FAIL    test/bug01 [build failed]"><pre class="notranslate"><code class="notranslate"># test/bug01
/tmp/go-build602734163/test/bug01/_test/_obj_test/bug.go:7: undefined: fmt.Printz
FAIL    test/bug01 [build failed]
</code></pre></div>
</li>
</ol>
<pre class="notranslate">What steps will reproduce the problem?

1. Create a test containing a syntax error, such as <a href="http://play.golang.org/p/cIDNFBtU7Z" rel="nofollow">http://play.golang.org/p/cIDNFBtU7Z</a>
2. go test .
3. go test . -coverprofile=c.out


What is the expected output?

Both invocations of go test report the syntax error in the same place.


What do you see instead?

$ go test .
...
./simpletest.go:8: undefined: hi
...

$ go test . -coverprofile=c.out
...
/var/folders/jw/xrvq7wz95p5bwvjyx9yc2npm09k844/T/go-build500502516/.../simpletest.go:9:
undefined: hi
...


Note that with -coverprofile, the error is (incorrectly) reported as being on line 9.

Which version are you using?  (run 'go version')

go version devel +6b0ef65315eb Wed Sep 04 13:26:49 2013 -0700 darwin/amd64


Please provide any additional information below.

Introduced since go 1.1.1.</pre>