The C++ front end uses two related internal representations for pointers to
members. A data-member pointer is an OFFSET_TYPE; a member-function pointer
is an ABI record containing a pointer-to-METHOD_TYPE and a this adjustment.
The Ada dumper handles neither internal type, so both forms produce malformed
declarations.
The offending C++ forms are:
struct Data_Object { int first; int field; };
using Data_Member =int Data_Object::*;
struct Method_Object {
virtualint virtual_method (int) const;
int nonvirtual_method (int) const;
};
using Method_Member =int (Method_Object::*) (int) const;
The unpatched mapper leaves both underlying types blank:
subtype Data_Member is ;
type Method_Member isrecord
uu_pfn : access ;
uu_delta : aliased long;
endrecordwith Convention => C_Pass_By_Copy;
On the Itanium C++ ABI used by every supported repository host, a data-member
pointer is a ptrdiff_t byte offset with -1 reserved for null. A
member-function pointer is two words: the first is either a function address or
an encoded virtual-table offset, and the second adjusts this. The corrected
Ada preserves those ABI values without claiming that Ada can dereference them:
subtype Data_Member is ptrdiff_t;
type Method_Member isrecord
uu_pfn : System.Address;
uu_delta : aliased long;
endrecordwith Convention => C_Pass_By_Copy;
System.Address is deliberately opaque: a virtual member-function encoding is
not an Ada access-to-subprogram value. Invocation still belongs in C++, but the
generated Ada can safely store and pass the complete value. The executable
regression obtains data, nonvirtual-function, virtual-function, and null member
pointers from C++, round-trips them through Ada, and asks C++ to apply or
classify them at -O0 and -O2.
Run it against an unpatched or patched compiler root:
GNAT rejects blank data-member and member-function pointer component types.
After the patch
Data, nonvirtual-function, virtual-function, and null member pointers round-trip through Ada and are applied or classified correctly by C++ at -O0 and -O2.
GNAT rejects blank data-member and member-function pointer component types.
After the patch
Data, nonvirtual-function, virtual-function, and null member pointers round-trip through Ada and are applied or classified correctly by 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 for the Itanium C++ ABI used by all supported hosts; 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.