NationalSecurityAgency/ghidra · error

%s: unknown demangling style `%s'

Error message

%s: unknown demangling style `%s'

What it means

The cplus-dem standalone driver accepts -s <style> to choose a demangling style (auto, gnu, lucid, arm, hp, edg, etc.). It calls cplus_demangle_name_to_style(optarg); if that returns unknown_demangling, the option string did not match any known style and the program prints this error and returns 1. It is an argument-validation failure at startup.

Source

Thrown at GPL/DemanglerGnu/src/demangler_gnu_v2_24/c/cplus-dem.c:5217

		  break;
		case 't':
		  flags |= DMGL_TYPES;
		  break;
		case 'i':
		  flags &= ~ DMGL_VERBOSE;
		  break;
		case 'v':
		  printf ("GNU %s (C++ demangler), version %s\n", program_name, program_version);
		  return 0;
		case '_':
		  strip_underscore = 1;
		  break;
		case 's':
			current_demangling_style
				= cplus_demangle_name_to_style (optarg);
			if (current_demangling_style == unknown_demangling)
			{
				fprintf (stderr, "%s: unknown demangling style `%s'\n",
					program_name, optarg);
				return (1);
			}
			break;
		}
	}

	if (optind < argc)
	{
		for ( ; optind < argc; optind++)
		{
			demangle_it (argv[optind]);
			putchar ('\n');
		}
	}
	else
	{
		switch (current_demangling_style)

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Run the demangler with --help (or -h) to list the exact style names this build accepts.
  2. Fix the typo / use the canonical style name (common ones: auto, gnu, lucid, arm, hp, edg, gnu-v3 where supported).
  3. Omit -s to use the default (auto) style if you do not need a specific one.
  4. Confirm the demangler binary version supports the desired style; rebuild/upgrade if needed.

Example fix

# before
$ c++filt -s gnu_v3 _Z3foov
... unknown demangling style `gnu_v3'

# after - use the exact name the build recognizes (often 'gnu-v3' or just default)
$ c++filt -s gnu-v3 _Z3foov
Defensive patterns

Strategy: validation

Validate before calling

// Validate the style name against the build's accepted set before invoking
const char *known[] = {"auto","gnu","lucid","arm","hp","edg","gnu-v3",NULL};
int ok = 0; for (int i=0; known[i]; ++i) if (!strcmp(style, known[i])) { ok=1; break; }
if (!ok) { fprintf(stderr,"unsupported style: %s\n", style); exit(2); }
execlp("c++filt", "c++filt", "-s", style, (char*)NULL);

Type guard

// (build-time) verify the style is recognized by this binary
enum demangling_style st = cplus_demangle_name_to_style(optarg);
bool isValidStyle = (st != unknown_demangling);

Try / catch

// CLI validation error with exit code 1; capture and handle in the caller
int rc = run_child({"c++filt", "-s", style, symbol});
if (rc != 0 && stderr_contains("unknown demangling style")) {
    // fall back to the default (auto) style or surface a config error
}

Prevention

When it happens

Trigger: Invoking the demangler with -s <value> where <value> is not one of the recognized style names. A typo, an unsupported style, or a style name from a different/older demangler version triggers it.

Common situations: Typo in the style name (e.g. 'gnu-v3' vs 'gnu'); passing a style that exists in a newer/older libiberty but not this build; confusing compiler style flags with demangler style flags; scripting that interpolates an empty or wrong variable as the style.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/b02f137327e7e4c3. Report an issue: GitHub.