Site icon Tomato Soup

Writing Safer C++: Introducing Visual Assist’s New Code Safety Inspections

C++ Safety is one of the most important conversations happening in software right now. From industry leaders to government agencies, including recent guidance coming from the U.S. government, there is a renewed call to strengthen memory safety and reduce classes of bugs that have historically plagued C and C++ projects.

But here is the reality: C++ remains one of the most critical languages in the world. Operating systems, embedded systems, real time control software, game engines, medical devices, aerospace systems, these all rely on C++ for its power, determinism, and performance. Rewriting the world in another language is unrealistic.

Instead, we need tools that help developers write safer C++ today.

With that goal in mind, the latest release of Visual Assist introduces a major new capability: C++ Safety Code Inspections, designed to surface correctness issues, prevent subtle runtime failures, and reinforce best practices drawn from CERT, the C++ Core Guidelines, and modern safety literature.

This post will guide you through how to enable the new feature, what categories of checkers are included, and what kinds of issues these inspections can help you catch before they reach production.

Enabling C++ Safety Code Inspections

Getting started takes just a few seconds. In Visual Studio:

  1. Go to Extensions – VAssistX – Visual Assist Options
  2. Open the Code Inspections section
  3. Enable Enable Code Inspections
  4. Choose one of the inspection sets:
    • VA Default, the standard Visual Assist inspections
    • C++ Safety, only the safety focused checkers
    • Combined (Recommended), the full suite of VA Default plus C++ Safety

We recommend Combined, since it brings together the long trusted VA inspections with the new safety focused rules for the strongest possible coverage.

You will also see a list of all checkers included in the selected set, and that is where the real power begins.

Understanding the New C++ Safety Checkers

The new feature groups inspections into thematic categories that address correctness, memory safety, undefined behavior, modern C++ best practices, and more. Here is a quick overview of what each category brings to your workflow:

1. Core Analysis

Catches the fundamental safety hazards in C++:

These are the kinds of bugs that turn into intermittent crashes, the worst kind to debug.

2. C++ Specific Issues

Monitors dangerous or incorrect use of core language features:

These checkers help prevent the subtle, low level mistakes that can undermine an otherwise correct system.

3. Nullability

Helps enforce contracts about pointer lifetimes and expectations:

This gives you stronger guarantees across API boundaries.

4. CERT Standards

Implements widely respected secure coding rules:

Ideal for industries that require compliance or audits.

5. C++ Core Guidelines

Reinforces modern best practices:

A great toolkit for teams modernizing a legacy codebase.

6. Bug Prevention

Targets patterns known to hide serious defects:

These are among the highest value checkers for catching issues early.

7. Modernization and Performance

Promotes cleaner, faster, more idiomatic code:

A cleaner codebase is almost always a safer codebase.

8. Concurrency

Surfaces potentially unsafe multi threaded operations.

What Do These Inspections Catch in Practice?

Example 1: Use After Move

std::string s = "Hello";

std::string t = std::move(s);


// ...

if (s.size() > 0) { /* undefined behavior */ }

After s is moved from, it should not be accessed. The checker flags this immediately, long before it becomes a nondeterministic crash in production.

Example 2: Null Dereference

class Widget
{
public:
	int value;
};

int main()
{
	Widget* w = 0;      
	int v = w->value;   // NullDereference

	return v;
}

Even in simple code, a null pointer dereference can lead to an immediate crash. In this example, w is null and the code still attempts to access w->value(). The C++ Safety inspections in Visual Assist detect this pattern instantly and warn you before the program ever runs.

These are exactly the kinds of issues that safety standards and auditors focus on, because they can cause unpredictable behavior or runtime failures. Visual Assist now helps you catch them early, making your C++ code safer and more robust by default.

Why This Matters for Modern C++

For teams working on embedded systems, real time applications, or any scenario where failure is not an option, safety tooling is becoming non negotiable. Even outside regulated industries, memory safety issues are expensive: crashes, CVEs, customer escalations, and time lost debugging.

Visual Assist’s new C++ Safety inspections provide:

C++ is not going away, and with the right tooling, it does not need to.

Conclusion: Safer C++ with Visual Assist

Whether you are maintaining a large legacy codebase, building safety critical software, or simply want tighter correctness guarantees, the new C++ Safety Code Inspections in Visual Assist bring modern static analysis directly into your everyday workflow.

By combining industry standards, smart analysis, and deep C++ knowledge, Visual Assist helps you write code that is not only fast and expressive, but also safe.

Enable the inspections, choose the Combined profile, and let Visual Assist guide you toward more robust, reliable C++ development.

Your code and your users will thank you.

VA Code Inspections: Automatically detect and fix code smells.

 

Exit mobile version