{"record":{"id":"c5e0c95e75776a36","repo":"golang/go","slug":"unclosed-quote","errorCode":null,"errorMessage":"unclosed quote","messagePattern":"unclosed quote","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/cgo/gcc.go","lineNumber":180,"sourceCode":"\t\t\tquoted = true\n\t\t\tquote = r\n\t\t\tcontinue\n\t\tcase unicode.IsSpace(r):\n\t\t\tif quoted || i > 0 {\n\t\t\t\tquoted = false\n\t\t\t\targs = append(args, string(arg[:i]))\n\t\t\t\ti = 0\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\targ[i] = r\n\t\ti++\n\t}\n\tif quoted || i > 0 {\n\t\targs = append(args, string(arg[:i]))\n\t}\n\tif quote != 0 {\n\t\terr = errors.New(\"unclosed quote\")\n\t} else if escaped {\n\t\terr = errors.New(\"unfinished escaping\")\n\t}\n\treturn args, err\n}\n\n// loadDebug runs gcc to load debug information for the File. The debug\n// information will be saved to the debugs field of the file, and be\n// processed when Translate is called on the file later.\n// loadDebug is called concurrently with different files.\nfunc (f *File) loadDebug(p *Package) {\n\tfor _, cref := range f.Ref {\n\t\t// Convert C.ulong to C.unsigned long, etc.\n\t\tcref.Name.C = cname(cref.Name.Go)\n\t}\n\n\tft := fileTypedefs{typedefs: make(map[string]bool)}\n\tnumTypedefs := -1","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/cgo/gcc.go#L162-L198","documentation":"Thrown by splitQuoted (src/cmd/cgo/gcc.go) when, after consuming the entire input string, an opening quote character (single or double) was never closed. The function remembers the quote type in `quote`; if it is non-zero at end-of-string, the parse is incomplete.","triggerScenarios":"splitQuoted receives a value with an unmatched quote. In cgo this value is typically the $CC / $GCC environment variable or a flag string split via quoted.Split. Example: CC='gcc -DFOO=\"bar' has an opening double quote with no closing quote.","commonSituations":"Mis-quoting CC/GCC environment variables in a Makefile, shell profile, or CI config; a stray trailing quote; copy-pasting a compiler invocation that lost its closing quote through shell expansion; CFLAGS with embedded spaces quoted incorrectly.","solutions":["Inspect the $CC (and $GCC) environment variable and balance the quotes.","Prefer a single set of outer quotes around quoted arguments, e.g. CC='gcc -DFOO=\"bar\"'.","Validate the value with `quoted.Split` (or `shlex`) in a scratch script before exporting it.","Unset CC/GCC temporarily to fall back to the default compiler and confirm the error source."],"exampleFix":"// before\nexport CC='gcc -DFOO=\"bar'\n// after\nexport CC='gcc -DFOO=\"bar\"'","handlingStrategy":"validation","validationCode":"// Pre-validate a CC/GCC value for balanced quotes before exporting it.\nfunc quotesBalanced(s string) bool {\n    var quote rune\n    escaped := false\n    for _, r := range s {\n        if escaped { escaped = false; continue }\n        if r == '\\\\' { escaped = true; continue }\n        if quote != 0 { if r == quote { quote = 0 }; continue }\n        if r == '\"' || r == '\\'' { quote = r }\n    }\n    return quote == 0\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always export CC/GCC with matching quote pairs; test in a scratch shell first.","Use `shlex`/`quoted.Split` to parse compiler-flag strings during build setup so errors surface early.","Audit Makefiles and CI env files for stray or unmatched quotes."],"tags":["cgo","cc","environment","quoting","shell"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}