Bug in unnamed_type_id_t
Closed this issue · 1 comments
mkurdej commented
Lines 146-149 (https://github.com/Manu343726/ctti/blob/master/include/ctti/type_id.hpp#L147) are currently:
return id_from_name(
CTTI_TYPE_ID_PRETTY_FUNCTION + CTTI_UNNAMED_TYPE_ID_PRETTY_FUNCTION_BEGIN,
CTTI_UNNAMED_TYPE_ID_PRETTY_FUNCTION_END - CTTI_UNNAMED_TYPE_ID_PRETTY_FUNCTION_BEGIN - 1
);
but should be:
return id_from_name(
CTTI_UNNAMED_TYPE_ID_PRETTY_FUNCTION + CTTI_UNNAMED_TYPE_ID_PRETTY_FUNCTION_BEGIN,
CTTI_UNNAMED_TYPE_ID_PRETTY_FUNCTION_END - CTTI_UNNAMED_TYPE_ID_PRETTY_FUNCTION_BEGIN - 1
);
Note the first macro missing UNNAMED.
So for the moment the hash given by unnamed_type_id() is completely incorrect as instead of hashing e.g. Typename (something)
, it hashes (example for GCC) ith T = (so
. That is, the hashed string starts 8 == strlen("unnamed_")
characters to early.
Manu343726 commented
Thanks a lot for noticing this. Hopefully the fix was as simple
as you menctioned. Cheers.