From c56434f6a616ae30cebac5d14d9fb6559a3fb157 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 29 Sep 2017 11:10:20 -0700 Subject: [PATCH] cmd/go: don't modify input slice in gccSupportsFlag Modifying the input slice broke the new test for whether gccgo supports -fgo-importcfg, as the test passed a slice of the argument slice it was in the process of building. Fixes #22089 Change-Id: I45444a82673223c46be0c8579da3e31a74c32d73 Reviewed-on: https://go-review.googlesource.com/67191 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- src/cmd/go/internal/work/build.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index ce5c71ae5a..0548840087 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -3333,7 +3333,8 @@ func (b *Builder) gccSupportsFlag(compiler []string, flag string) bool { } b.flagCache = make(map[[2]string]bool) } - cmdArgs := append(compiler, flag, "-c", "trivial.c") + cmdArgs := append([]string(nil), compiler...) + cmdArgs = append(cmdArgs, flag, "-c", "trivial.c") if cfg.BuildN || cfg.BuildX { b.Showcmd(b.WorkDir, "%s", joinUnambiguously(cmdArgs)) if cfg.BuildN { -- 2.48.1