tdesc_get_features_xml() logic

Nicholas Kulikov via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAOOM2W1kxEx0DWfj0fe2PNzRjxZK8mnhfWApSoMRKtVRGT74=g@mail.gmail.com>
Hello,

What is the idea to check the precondition `tdesc->xmltarget != NULL`
in assert while there is (the code below) conditional logic which
handles this case? Do I miss something or there is a flaw in assert
logic?

gdbserver/tdesc.cc:

const char *
tdesc_get_features_xml (const target_desc *tdesc)
{
  /* Either .xmltarget or .features is not NULL.  */
  gdb_assert (tdesc->xmltarget != NULL
              || (!tdesc->features.empty ()
                  && tdesc->arch != NULL));

  if (tdesc->xmltarget == NULL)
    {
      std::string buffer ("@");
      print_xml_feature v (&buffer);
      tdesc->accept (v);
      tdesc->xmltarget = xstrdup (buffer.c_str ());
    }

  return tdesc->xmltarget;
}

This assert triggered at first call of tdesc_get_features_xml() when
tdesc->xmltarget is NULL.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.