Skip to content

fix inline directive passing on unrelated compiler output - #26

Open
siyul-park wants to merge 1 commit into
jordanlewis:masterfrom
siyul-park:fix-inline-callsite-false-pass
Open

siyul-park wants to merge 1 commit into
jordanlewis:masterfrom
siyul-park:fix-inline-callsite-false-pass

Conversation

@siyul-park

Copy link
Copy Markdown

Summary

A callsite of a //gcassert:inline function is marked as passed when any -m output is reported at the call's line and column. The message is not checked. Escape analysis also reports at the call's opening parenthesis, so a call that was never inlined still passes:

var sink interface{}

func escapingCall() {
	sink = noInlineNumber(1000)
}

//gcassert:inline
//go:noinline
func noInlineNumber(n int) int {
	return n
}
testdata/inline_escape.go:16:6: cannot inline noInlineNumber: marked go:noinline
testdata/inline_escape.go:6:23: noInlineNumber(1000) escapes to heap

Before this change, gcassert reported no failure for this code.

The fix accepts a callsite only on an inlining call to message. The directive-on-the-line path already does this check.

Test plan

  • Added testdata/inline_escape.go as a regression test. It fails before the fix and passes after.
  • go test -race ./... passes.

🤖 Generated with Claude Code

A callsite of a //gcassert:inline function was treated as inlined when
any compiler output was reported at the call's position. Escape analysis
reports at the same position, so a call that was not inlined could pass,
for example when its result escapes to the heap.

Only accept an "inlining call to" message at the callsite, as the
directive-on-the-line path already does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant