C++20 gives char8_t a distinct fundamental type with the size, alignment,
and unsigned representation of unsigned char. The Ada spec dumper prints the
C++ spelling directly, but GNAT's Interfaces.C has no char8_t declaration.
The offending C++ is a function with a char8_t parameter and result:
The unpatched mapper produces an Ada type name that does not exist:
function char8_value (value : char8_t) return char8_t
with Import =>True,
Convention => CPP,
External_Name =>"_Z11char8_valueDu";
The correct generated binding uses the ABI-equivalent type already provided by
Interfaces.C while retaining the C++ mangled name that identifies char8_t:
function char8_value (value : unsigned_char) return unsigned_char
with Import =>True,
Convention => CPP,
External_Name =>"_Z11char8_valueDu";
The executable regression compiles the generated Ada and round-trips a value
through the C++ function at -O0 and -O2. The existing wchar_t, char16_t,
and char32_t mappings remain unchanged.
Run it against an unpatched or patched compiler root:
withInterfaces.C; useInterfaces.C;
with Char8_Type_C;
procedure Char8_Type_Consumer ispackage Bindings renames Char8_Type_C;
Value : constant unsigned_char :=16#A5#;
beginifBindings.char8_value (Value) /= Value thenraise Program_Error with"char8_t value did not round-trip";
endif;
end Char8_Type_Consumer;
GNAT rejects the generated specification because char8_t is undefined.
After the patch
The binding uses Interfaces.C.unsigned_char and round-trips a char8_t value through C++ at -O0 and -O2.
Upstream issue
Pending GCC Bugzilla filing.
Upstream submission
Not yet filed or submitted upstream.
Provenance
Repository-authored GCC patch and executable regression; exact application verified locally against the pinned Darwin release identities. Pinned FSF release application is required by Linux CI.
Licensing
GCC-derived compiler hunks remain GPL-3.0-or-later. The new test is proposed for the GCC testsuite under GCC project terms.