{"record":{"id":"141886c6f4a0a37b","repo":"NationalSecurityAgency/ghidra","slug":"s-unknown-demangling-style-s-n","errorCode":null,"errorMessage":"%s: unknown demangling style `%s'\\n","messagePattern":"(.+?): unknown demangling style `(.+?)'\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/cxxfilt.c","lineNumber":217,"sourceCode":"\t  break;\n\tcase 't':\n\t  flags |= DMGL_TYPES;\n\t  break;\n\tcase 'i':\n\t  flags &= ~ DMGL_VERBOSE;\n\t  break;\n\tcase 'v':\n\t  // print_version (\"c++filt\");  // Changed 10/31/23\n\t  printf (\"c++filt 2.41\\n\"); // Changed 10/31/23\n\t  return 0;\n\tcase '_':\n\t  strip_underscore = 1;\n\t  break;\n\tcase 's':\n\t  style = cplus_demangle_name_to_style (optarg);\n\t  if (style == unknown_demangling)\n\t    {\n\t      fprintf (stderr, \"%s: unknown demangling style `%s'\\n\",\n\t\t       program_name, optarg);\n\t      return 1;\n\t    }\n\t  cplus_demangle_set_style (style);\n\t  break;\n\t}\n    }\n\n  if (optind < argc)\n    {\n      for ( ; optind < argc; optind++)\n\t{\n\t  demangle_it (argv[optind]);\n\t  putchar ('\\n');\n\t}\n\n      return 0;\n    }","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/cxxfilt.c#L199-L235","documentation":"c++filt's -s option accepts a demangling style name. The name is resolved by cplus_demangle_name_to_style(), which returns unknown_demangling if the string doesn't match any known style. The tool prints the error and returns exit code 1.","triggerScenarios":"User passes `-s bogus`; cplus_demangle_name_to_style(optarg) returns unknown_demangling. Valid styles include auto, gnu, lucid, arm, hp, edg, gnu-v3, java, gnat, dlang, rust.","commonSituations":"Typo in the style name (e.g. `gnu3` instead of `gnu-v3`); using a style name from a different version; misunderstanding the supported style list.","solutions":["Use a valid style name (run `c++filt --help` to see the list)","Common valid styles: gnu-v3, auto, java, gnat, dlang, rust","Fix the typo in the style name"],"exampleFix":"// before\n./c++filt -s gnu3\n// after\n./c++filt -s gnu-v3","handlingStrategy":"validation","validationCode":"// Validate the style name before passing to -s\n#include <string.h>\nstatic const char *valid_styles[] = {\n    \"auto\", \"gnu\", \"lucid\", \"arm\", \"hp\", \"edg\",\n    \"gnu-v3\", \"java\", \"gnat\", \"dlang\", \"rust\", NULL\n};\nstatic int is_valid_style(const char *s) {\n    for (int i = 0; valid_styles[i]; i++)\n        if (strcmp(valid_styles[i], s) == 0) return 1;\n    return 0;\n}\n// Use before calling the tool or calling cplus_demangle_name_to_style\nif (!is_valid_style(optarg)) {\n    fprintf(stderr, \"Unknown style '%s'. Valid: auto, gnu-v3, java, ...\\n\", optarg);\n    exit(1);\n}","typeGuard":"static int is_known_demangle_style(const char *name) {\n    return cplus_demangle_name_to_style(name) != unknown_demangling;\n}","tryCatchPattern":"enum demangling_styles style = cplus_demangle_name_to_style(optarg);\nif (style == unknown_demangling) {\n    fprintf(stderr, \"Unknown style '%s'. Use --help for valid styles.\\n\", optarg);\n    return EXIT_FAILURE;\n}\ncplus_demangle_set_style(style);","preventionTips":["Check style names against a known list before applying","Provide a --help listing of valid styles","Use auto style to let the demangler detect the format automatically"],"tags":["cli","demangling","c-plus-plus","cxxfilt","c"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}