Using type_info::name() wrong

Bug #980463 reported by Paul J. Lucas
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
High
Paul J. Lucas

Bug Description

In class_serializer.h, the definition of the CHECK_CLASS_NAME macro:

  #define CHECK_CLASS_NAME(class_name) \
  if (ar.is_serializing_out() && !ar.is_serialize_base_class()) \
  { \
    assert(strstr(typeid(*this).name(), #class_name)); \
  }

The string returned by type_info::name() is implementation-dependent and has no guarantees about its content or format. In this case, you can not legitimately test to see, for some class type C, if typeid(C).name() contains the string literal "C".

However, you can legitimately compare two name() strings for equality. The above should be rewritten as:

    assert(::strcmp(typeid(*this).name(), typeid(class_name).name()) == 0);

Related branches

Changed in zorba:
status: New → In Progress
Changed in zorba:
status: In Progress → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.