Examples of errors detected by the V772 diagnostic


V772. Calling the 'delete' operator for a void pointer will cause undefined behavior.


Haiku Operation System

V772 Calling a 'delete' operator for a void pointer will cause undefined behavior. Hashtable.cpp 207


void
Hashtable::MakeEmpty(int8 keyMode,int8 valueMode)
{
  ....
  for (entry = fTable[index]; entry; entry = next) {
    switch (keyMode) {
      case HASH_EMPTY_DELETE:
        // TODO: destructors are not called!
        delete (void*)entry->key;
        break;
      case HASH_EMPTY_FREE:
        free((void*)entry->key);
        break;
    }
    switch (valueMode) {
      case HASH_EMPTY_DELETE:
        // TODO: destructors are not called!
        delete entry->value;
        break;
      case HASH_EMPTY_FREE:
        free(entry->value);
        break;
    }
    next = entry->next;
    delete entry;
  }
  ....
}


Bugs Found

Checked Projects
361
Collected Errors
13 417