Unicorn with delicious cookie
Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter
to the top
>
>
>
Examples of errors detected by the V572…

Examples of errors detected by the V572 diagnostic

V572. Object created using 'new' operator is immediately cast to another type. Consider inspecting the expression.


wxWidgets

V572 It is odd that the object which was created using 'new' operator is immediately cast to another type. base appbase.cpp 812


class wxFontMapper : public wxFontMapperBase
{
  ....
}

wxFontMapper *wxConsoleAppTraitsBase::CreateFontMapper()
{
  return (wxFontMapper *)new wxFontMapperBase;
}

Similar errors can be found in some other places:

  • V572 It is odd that the object which was created using 'new' operator is immediately cast to another type. base fmapbase.cpp 428

Cocos2d-x

V572 It is odd that the object which was created using 'new' operator is immediately cast to another type. ccactiontiledgrid.cpp 322


struct Tile
{
  Vec2    position;
  Vec2    startPosition;
  Size    delta;
};

Tile* _tiles;

void ShuffleTiles::startWithTarget(Node *target)
{
  ....
  _tiles = (struct Tile *)new Tile[_tilesCount];  // <=
  Tile *tileArray = (Tile*) _tiles;               // <=
  ....
}

Similar errors can be found in some other places:

  • V572 It is odd that the object which was created using 'new' operator is immediately cast to another type. luabasicconversions.cpp 1301

Tizen

V572 It is odd that the object which was created using 'new' operator is immediately cast to another type. scim_socket.cpp 136


struct sockaddr_un
{
  sa_family_t sun_family;
  char sun_path[108];
};

struct sockaddr_in
{
  sa_family_t sin_family;
  in_port_t sin_port;
  struct in_addr sin_addr;
  unsigned char sin_zero[sizeof (struct sockaddr) -
    (sizeof (unsigned short int)) -
    sizeof (in_port_t) -
    sizeof (struct in_addr)];
};

struct sockaddr
{
  sa_family_t sa_family;
  char sa_data[14];
};

class SocketAddress::SocketAddressImpl
{
  struct sockaddr *m_data;
  ....
  SocketAddressImpl (const SocketAddressImpl &other)
  {
    ....
    case SCIM_SOCKET_LOCAL:
        m_data = (struct sockaddr*) new struct sockaddr_un; // <=
        len = sizeof (sockaddr_un);
        break;
    case SCIM_SOCKET_INET:
        m_data = (struct sockaddr*) new struct sockaddr_in; // <=
        len = sizeof (sockaddr_in);
        break;
    ....
  }

  ~SocketAddressImpl () {
    if (m_data) delete m_data;                              // <=
  }
};

Structures of type sockaddr_un and sockaddr_in are created. However, they are stored and destroyed as sockaddr structures. All three types of the mentioned structures are not related among themselves. Three different structures have different sizes.

Similar errors can be found in some other places:

  • V572 It is odd that the object which was created using 'new' operator is immediately cast to another type. scim_socket.cpp 140
  • V572 It is odd that the object which was created using 'new' operator is immediately cast to another type. scim_socket.cpp 167
  • V572 It is odd that the object which was created using 'new' operator is immediately cast to another type. scim_socket.cpp 171

close form

Remplissez le formulaire ci‑dessous en 2 étapes simples :

Vos coordonnées :

Étape 1
Félicitations ! Voici votre code promo !

Type de licence souhaité :

Étape 2
Team license
Enterprise licence
** En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité
close form
Demandez des tarifs
Nouvelle licence
Renouvellement de licence
--Sélectionnez la devise--
USD
EUR
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
La licence PVS‑Studio gratuit pour les spécialistes Microsoft MVP
close form
Pour obtenir la licence de votre projet open source, s’il vous plait rempliez ce formulaire
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
I want to join the test
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
check circle
Votre message a été envoyé.

Nous vous répondrons à


Si l'e-mail n'apparaît pas dans votre boîte de réception, recherchez-le dans l'un des dossiers suivants:

  • Promotion
  • Notifications
  • Spam