Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V596. Object was created but is not...
menu mobile close menu
Additional information
toggle menu Contents

V596. Object was created but is not used. Check for missing 'throw' keyword.

Dec 23 2011

The analyzer has detected a strange use of the std::exception class or derived class. The analyzer generates this warning when an object of the std::exception / CException type is created but not being used.

For example:

if (name.empty())
  std::logic_error("Name mustn't be empty");

The error is this: the key word 'throw' is missing by accident. As a result, this code does not generate an exception in case of an error. This is the fixed code:

if (name.empty())
  throw std::logic_error("Name mustn't be empty");

This diagnostic is classified as:

You can look at examples of errors detected by the V596 diagnostic.