{"record":{"id":"c37f055f6ae0a154","repo":"golang/go","slug":"asan-the-version-of-go-env-cc-could-not-be-pa","errorCode":null,"errorMessage":"-asan: the version of $(go env CC) could not be parsed","messagePattern":"-asan: the version of \\$\\(go env CC\\) could not be parsed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/init.go","lineNumber":439,"sourceCode":"\t\t\t\treturn err\n\t\t\t}\n\t\t\tif compiler.minor, err = strconv.Atoi(string(match[2])); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn nil\n\t\t}()\n\t})\n\treturn compiler.version, compiler.err\n}\n\n// compilerRequiredAsanVersion is a copy of the function defined in\n// cmd/cgo/internal/testsanitizers/cc_test.go\n// compilerRequiredAsanVersion reports whether the compiler is the version\n// required by Asan.\nfunc compilerRequiredAsanVersion() error {\n\tcompiler, err := compilerVersion()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"-asan: the version of $(go env CC) could not be parsed\")\n\t}\n\n\tswitch compiler.name {\n\tcase \"gcc\":\n\t\tif runtime.GOARCH == \"ppc64le\" && compiler.major < 9 {\n\t\t\treturn fmt.Errorf(\"-asan is not supported with %s compiler %d.%d\\n\", compiler.name, compiler.major, compiler.minor)\n\t\t}\n\t\tif compiler.major < 7 {\n\t\t\treturn fmt.Errorf(\"-asan is not supported with %s compiler %d.%d\\n\", compiler.name, compiler.major, compiler.minor)\n\t\t}\n\tcase \"clang\":\n\t\tif compiler.major < 9 {\n\t\t\treturn fmt.Errorf(\"-asan is not supported with %s compiler %d.%d\\n\", compiler.name, compiler.major, compiler.minor)\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"-asan: C compiler is not gcc or clang\")\n\t}\n\treturn nil","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/init.go#L421-L457","documentation":"When -asan is requested, the go command calls compilerVersion() which runs `$(go env CC) --version`, then (for gcc) `CC -v`, parsing `gcc version N.M` or `clang version N.M`. If running the compiler fails, or the matched version digits cannot be parsed as integers, compilerVersion returns an error and this wraps it. The build aborts because the Asan support requirement cannot be verified without a known compiler version.","triggerScenarios":"Fires in compilerRequiredAsanVersion when compilerVersion() returns a non-nil error - i.e. CC --version or CC -v failed to execute, or strconv.Atoi on the matched major/minor failed.","commonSituations":"$CC unset or pointing to a non-existent/wrapper compiler whose --version output is non-standard or fails, a compiler that exits non-zero on --version, or a version string whose digits are not pure integers.","solutions":["Ensure `go env CC` points to real gcc or clang: run `$(go env CC) --version` and check the output","Upgrade the C compiler to an Asan-capable version (gcc >= 7, clang >= 9)","Drop -asan if AddressSanitizer is not required"],"exampleFix":"// before (unparseable / missing compiler)\nCC=my-wrapper go build -asan ./...\n// after\nCC=gcc go build -asan ./...","handlingStrategy":"validation","validationCode":"// Verify CC is real gcc/clang with parseable version before -asan\ncc := os.Getenv(\"CC\")\nif cc == \"\" { cc = \"cc\" }\nout, err := exec.Command(cc, \"--version\").Output()\nif err != nil || (!bytes.HasPrefix(out, []byte(\"gcc\")) && !bytes.Contains(out, []byte(\"clang version\"))) {\n    return fmt.Errorf(\"CC must be gcc or clang with parseable --version for -asan\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set CC to a real gcc (>= 7) or clang (>= 9) for -asan builds","Run `$(go env CC) --version` and confirm parseable gcc/clang output","Avoid wrapper scripts or non-standard compilers when using -asan"],"tags":["go-toolchain","asan","cgo","compiler-version","environment"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}