{"record":{"id":"5396785c0426ccf9","repo":"golang/go","slug":"unfinished-escaping","errorCode":null,"errorMessage":"unfinished escaping","messagePattern":"unfinished escaping","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/cgo/gcc.go","lineNumber":182,"sourceCode":"\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\n\tfor len(ft.typedefs) > numTypedefs {\n\t\tnumTypedefs = len(ft.typedefs)","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/cgo/gcc.go#L164-L200","documentation":"Thrown by splitQuoted (src/cmd/cgo/gcc.go) when the input string ends while still in escape mode — i.e. the final character was a backslash with nothing following it. The `escaped` flag stays true at end-of-string.","triggerScenarios":"splitQuoted receives a value whose last character is '\\'. For cgo this is again the $CC/$GCC variable or a flag string. Example: CC='gcc -DFOO=bar\\' leaves the parser expecting an escaped character that never arrives.","commonSituations":"A trailing backslash in CC/GCC from a line-continuation that got collapsed incorrectly; copy-paste artifacts; Makefile $(...) expansions that produce a dangling backslash; shell-quoting mistakes where '\\' was meant literally but appears at the end.","solutions":["Remove or double the trailing backslash in the $CC / $GCC value.","If a literal backslash is required at the end, escape it as '\\\\'.","Re-export CC without the trailing backslash and rebuild.","Echo the variable with `printf '%s\\n' \"$CC\" | cat -A` to reveal hidden trailing characters."],"exampleFix":"// before\nexport CC='gcc -DFOO=bar\\'\n// after\nexport CC='gcc -DFOO=bar\\\\'","handlingStrategy":"validation","validationCode":"// Reject a CC/GCC value ending in an unescaped backslash.\nfunc endsClean(s string) bool {\n    if s == \"\" { return true }\n    backslashes := 0\n    for i := len(s)-1; i >= 0 && s[i] == '\\\\'; i-- { backslashes++ }\n    return backslashes%2 == 0\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid trailing backslashes in CC/GCC unless doubled.","Print CC with `cat -A` to reveal hidden trailing characters before building.","Prefer absolute compiler paths without shell metacharacters."],"tags":["cgo","cc","environment","escaping","shell"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}