Public bug reported:

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);

** Affects: zorba
     Importance: High
     Assignee: Paul J. Lucas (paul-lucas)
         Status: New

-- 
You received this bug notification because you are a member of Zorba
Coders, which is the registrant for Zorba.
https://bugs.launchpad.net/bugs/980463

Title:
  Using type_info::name() wrong

Status in Zorba - The XQuery Processor:
  New

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);

To manage notifications about this bug go to:
https://bugs.launchpad.net/zorba/+bug/980463/+subscriptions

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to