Quantcast
Channel: Category Name
Viewing all articles
Browse latest Browse all 5971

C++ Core Check in Visual Studio 2017 15.6 Preview 2

$
0
0

This post was written by Sergiy Oryekhov.

Note that some of the links to docs.microsoft.com do not yet resolve. Not all of the official documentation has yet been written for this topic.

Visual Studio 2017 15.6 Preview 2 includes a set of updates to the C++ Core Guidelines Check extension. We added more checks to help with the effort of making code cleaner, more secure and maintainable. This document is a quick overview of the new rules. More detailed information about these rules as well as an updated list of available rules can be found here:

This release also has general improvements in user experience for native code analysis tools:

C++ Static Analysis Improvements for Visual Studio 2017 15.6 Preview 2

New rule sets

Two new rule categories are introduced in this release with corresponding rule set files that can be chosen in project configuration to filter static analysis results:

  • Arithmetic rulesThese rules focus on cases where arithmetic operations can lead to loss of data, undefined behavior, or overflows.
  • Lifetime rulesThis set of rules was formerly released in the form of experimental C++ core check (which is still available). For 15.6 it was completely rewritten and the first version of it is ready for evaluation. The primary focus is to catch very dangerous situations in which code obtains access to a memory location which is no longer valid because its content’s lifetime ended (e.g. local variable is no longer in scope and was destroyed).

New rules

  • Class rules

    • C26433 OVERRIDE_EXPLICITLY When a method overrides a base virtual function it should clearly state this by using the ‘override’ specifier.
    • C26435 SINGLE_VIRTUAL_SPECIFICATION Methods should clearly state the kind of their virtual behavior by using a single specifier (‘virtual’, ‘override’, or ‘final’).
    • C26443 NO_EXPLICIT_DTOR_OVERRIDE Destructors are very special methods and guidelines for them differ from the OVERRIDE_EXPLICITLY rule: it is recommended to rely on implicit overriding if the base class has a virtual destructor.
  • Declaration rules

    • C26444 NO_UNNAMED_RAII_OBJECTS This rule helps to detect some common cases where a potentially expensive object is created and immediately discarded. This is often an indication of ignored call results or inefficient resource handling.

In closing

Good tools can help you to maintain and upgrade your code. The C++ Core Guidelines are a great place to start, and the C++ Core Guidelines Checker can help you to clean up your code and keep it clean. Try out the expanded C++ Core Guidelines Checker in Visual Studio 2017 version 15.6 and let us know what you think.

If you have any feedback or suggestions for us, let us know. We can be reached via the comments below, via email (visualcpp@microsoft.com) and you can provide feedback via Help > Report A Problem in the product, or via Developer Community. You can also find us on Twitter (@VisualC) and Facebook (msftvisualcpp).


Viewing all articles
Browse latest Browse all 5971

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>