[cxx-abi-dev] std::type_info::hash_code/before
John McCall
rjmccall at apple.com
Tue Oct 4 20:22:15 UTC 2016
> On Oct 4, 2016, at 4:25 AM, David Vandevoorde <daveed at edg.com> wrote:
> Shouldn't the ABI document specify how type_info entries are collated and hashed with their before() and hash_code() members?
Yes, that seems reasonable. It's only necessary for interoperation of multiple standard libraries on a platform, but that's a thing.
Since the ABI only formally guarantees that the names are uniqued, I think the obviously correct way of implementing these is to compare name pointers in before() and reinterpret the name pointer as the result of hash_code(). That is what libc++ seems to do. I don't have a recent libstdc++ header around; the ancient one I do have uses that rule for before() and doesn't implement hash_code(), but IIRC these days libstdc++ uses a variant ABI for type_info anyway.
Darwin ARM64 uses a variant ABI that does not guarantee that names are uniqued, and so we need a different rule there to handle that; in particular, it does actually have to fall back on string comparisons and string hashes for non-unique type info.
John.
More information about the cxx-abi-dev
mailing list