<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Unicorn Developer</title>
    <description>The latest articles on DEV Community by Unicorn Developer (@pvsdev).</description>
    <link>https://dev.to/pvsdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1110345%2F0615f05a-4746-4c6f-89ff-a4ef95008a77.png</url>
      <title>DEV Community: Unicorn Developer</title>
      <link>https://dev.to/pvsdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pvsdev"/>
    <language>en</language>
    <item>
      <title>Let’s make a programming language. Variables</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Wed, 08 Jul 2026 12:44:33 +0000</pubDate>
      <link>https://dev.to/pvsdev/lets-make-a-programming-language-variables-2pl6</link>
      <guid>https://dev.to/pvsdev/lets-make-a-programming-language-variables-2pl6</guid>
      <description>&lt;p&gt;We continue building our own programming language from scratch. In this session, we’ll take the next step by adding variables to the language.&lt;/p&gt;

&lt;p&gt;So far, our programs have consisted of a single expression built from smaller language constructs. Now it’s time to evolve the language.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9ys9m7jjl5te76jqrb02.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9ys9m7jjl5te76jqrb02.png" alt=" " width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of parsing a single expression, we'll introduce a list of declarations, allowing our language to support variable declarations and laying the groundwork for more complex programs.&lt;/p&gt;

&lt;p&gt;During the webinar, Yuri will walk through the implementation step by step, showing how variables are represented and processed in our language, and how to add this functionality to your language in C++.&lt;/p&gt;

&lt;p&gt;This webinar is designed for developers who want to understand how programming languages work under the hood - not just how to use them.&lt;/p&gt;

&lt;p&gt;Register to join the session. All registered participants will receive the recording of this webinar, along with recordings of all previous webinars in the series, after the webinar has concluded.&lt;/p&gt;

&lt;p&gt;If you missed any of the previous sessions, don't worry. All registered participants get access to the recordings. You can also catch up on YouTube or the PVS-Studio website.&lt;/p&gt;

&lt;p&gt;First talk: &lt;strong&gt;&lt;a href="https://pvs-studio.com/en/blog/video/11585?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=webinar&amp;amp;utm_content=web5" rel="noopener noreferrer"&gt;Let's make a programming language. Intro&lt;br&gt;
&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Second talk: &lt;strong&gt;&lt;a href="https://pvs-studio.com/en/blog/video/11644?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=webinar&amp;amp;utm_content=web5" rel="noopener noreferrer"&gt;Let's make a programming language. Grammars&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Third talk: &lt;strong&gt;&lt;a href="https://pvs-studio.com/en/blog/video/11665?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=webinar&amp;amp;utm_content=web5" rel="noopener noreferrer"&gt;Let's make a programming language. Lexer&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fourth talk: &lt;strong&gt;&lt;a href="https://pvs-studio.com/en/blog/video/11709/?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=webinar&amp;amp;utm_content=web6" rel="noopener noreferrer"&gt;Let's make a programming language. Parser&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fifth talk: &lt;strong&gt;&lt;a href="https://youtu.be/ZY7N6ALq2Bw" rel="noopener noreferrer"&gt;Let’s make a programming language. AST&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Register now to join us live, ask your questions, and get the most out of the session. Don't miss the chance to build your own language alongside an experienced developer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://pvs-studio.com/en/webinar/31/?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=webinar&amp;amp;utm_content=web6" rel="noopener noreferrer"&gt;Join us&lt;/a&gt;&lt;/strong&gt; on July 23, 1:00 PM UTC+1!&lt;/p&gt;

&lt;p&gt;P.S. Don't forget to check your inbox and confirm your registration!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>cpp</category>
      <category>webinar</category>
    </item>
    <item>
      <title>Inside BotSharp: Finding bugs in the .NET AI platform's code</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Tue, 07 Jul 2026 14:21:32 +0000</pubDate>
      <link>https://dev.to/pvsdev/inside-botsharp-finding-bugs-in-the-net-ai-platforms-code-13g0</link>
      <guid>https://dev.to/pvsdev/inside-botsharp-finding-bugs-in-the-net-ai-platforms-code-13g0</guid>
      <description>&lt;p&gt;C# has a reputation as a language for enterprise development but not for machine learning. BotSharp pushes back on that idea with a powerful AI platform built on .NET. We'll walk through the project and the bugs we found in its source code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3e36lv5292do79p4osm4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3e36lv5292do79p4osm4.png" alt=" " width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Foreword
&lt;/h2&gt;

&lt;p&gt;Python has long dominated machine learning, while C# made its name in enterprise systems, web development, and game development. That's starting to shift. Tools like ML.NET and Microsoft Agent Framework show that .NET can hold its own in AI development too. BotSharp is one of these tools, and it's what this article is about. Mostly, though, we'll be digging into the bugs we found in its source code using the PVS-Studio static analyzer. Let's get started. &lt;/p&gt;

&lt;h2&gt;
  
  
  A word about the project
&lt;/h2&gt;

&lt;p&gt;BotSharp is an open source framework written in C#. It's built for creating single-agent and multi-agent systems, where one or more AI models drive the decision-making. These models can process and generate multimedia data, and they can act by calling the tools they're given.&lt;/p&gt;

&lt;p&gt;So how does BotSharp differ from &lt;a href="https://learn.microsoft.com/en-us/semantic-kernel/" rel="noopener noreferrer"&gt;Semantic Kernel&lt;/a&gt;? Both currently solve similar problems, offering components for building LLM-powered agent systems. What sets BotSharp apart is a higher level of abstraction and built-in infrastructure for managing agents and dialogs, which makes it faster to deploy typical agent-based solutions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg9uz9p4wx9yevohk9gz2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg9uz9p4wx9yevohk9gz2.png" alt=" " width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picture 1 — The BotSharp web interface, provided for visualizing agent-based systems&lt;/p&gt;

&lt;p&gt;You can find more on BotSharp in the framework's &lt;a href="https://botsharp.readthedocs.io/en/latest/quick-start/overview.html" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;. For now, though, let's get to the interesting part, the bugs we found in its code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Error review
&lt;/h2&gt;

&lt;p&gt;PVS-Studio found the bugs covered below in the project's version 5.2, the latest one available as of this writing.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;PVS-Studio is a static analysis tool for C#, C, C++, and Java code, built to catch bugs and potential vulnerabilities. Support for Go, JavaScript, and TypeScript is on the way too, and you can &lt;a href="https://pvs-studio.com/en/pvs-studio-eap/" rel="noopener noreferrer"&gt;sign up&lt;/a&gt; now to test those. For more on PVS-Studio, check out the &lt;a href="https://pvs-studio.com/en/pvs-studio/try-free/?utm_source=website&amp;amp;utm_medium=devto&amp;amp;utm_campaign=article&amp;amp;utm_content=1391" rel="noopener noreferrer"&gt;official website&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Unused parameter
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SettingService&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ISettingService&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;ILogger&lt;/span&gt; &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;SettingService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IServiceProvider&lt;/span&gt; &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="n"&gt;IConfiguration&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="n"&gt;ILogger&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;SettingService&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;_services&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="n"&gt;_config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v3117/" rel="noopener noreferrer"&gt;V3117&lt;/a&gt;. Constructor parameter 'logger' is not used. &lt;a href="https://github.com/SciSharp/BotSharp/blob/b52cbf57f05a71a59d63b7e9f5922952a75b3ba8/src/Infrastructure/BotSharp.Core/Infrastructures/SettingService.cs#L15" rel="noopener noreferrer"&gt;SettingService.cs 15&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just a sloppy typo: the &lt;code&gt;logger&lt;/code&gt; parameter gets passed into the constructor, but nobody assigns it to the matching &lt;code&gt;_logger&lt;/code&gt; field. Nothing breaks so far, simply because that the &lt;code&gt;_logger&lt;/code&gt; field isn't used anywhere yet. But it's still a trap waiting to be triggered.&lt;/p&gt;

&lt;p&gt;Sooner or later someone may want to add logging. They'll spot the field already sitting there, write the usual logging call, and the code will compile without any complaints. Then the first call in prod throws a &lt;code&gt;NullReferenceException&lt;/code&gt; out of nowhere. Landmines like this are exactly the kind of thing you don't want to find later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Missing case in a switch statement
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="nf"&gt;UpdateAgentTask&lt;/span&gt;&lt;span class="p"&gt;(....)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;AgentTaskField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="n"&gt;metaData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;AgentTaskField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="n"&gt;metaData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Description&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;AgentTaskField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="n"&gt;metaData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Enabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Enabled&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;AgentTaskField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;AgentTaskField&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;All&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="n"&gt;metaData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;metaData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Description&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;metaData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Enabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Enabled&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v3002/" rel="noopener noreferrer"&gt;V3002&lt;/a&gt;. The switch statement does not cover all values of the 'AgentTaskField' enum: Status. &lt;a href="https://github.com/SciSharp/BotSharp/blob/b52cbf57f05a71a59d63b7e9f5922952a75b3ba8/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.AgentTask.cs#L234" rel="noopener noreferrer"&gt;FileRepository.AgentTask.cs 234&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This &lt;code&gt;switch&lt;/code&gt; statement updates the &lt;code&gt;metaData&lt;/code&gt; properties based on the flag it receives. Nearly every value in the &lt;code&gt;AgentTaskField&lt;/code&gt; enum shows up here, only &lt;code&gt;Status&lt;/code&gt; got left out. &lt;/p&gt;

&lt;p&gt;Because of this gap, the app misbehaves in two different scenarios. If there's an explicit request to update &lt;code&gt;Status&lt;/code&gt;, the &lt;code&gt;switch&lt;/code&gt; just ignores it and &lt;code&gt;metaData&lt;/code&gt; stays unchanged. The  &lt;code&gt;case AgentTaskField.All&lt;/code&gt; block has a problem too: it's supposed to overwrite every &lt;code&gt;metadata&lt;/code&gt; property with &lt;code&gt;task&lt;/code&gt; properties, but since &lt;code&gt;Status&lt;/code&gt; got left out, that block doesn't fully do what it's supposed to.&lt;/p&gt;

&lt;p&gt;It's a good illustration of how extending an &lt;code&gt;enum&lt;/code&gt; without checking every &lt;code&gt;switch&lt;/code&gt; statement that depends on it can quietly introduce hidden bugs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Losing a parameter's value
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;FunctionCallFromLlm&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;GetNextInstruction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;....,&lt;/span&gt; 
  &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;RoleDialogModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;dialogs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="n"&gt;dialogs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;RoleDialogModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;RoleDialogModel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;AgentRole&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;User&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;FunctionName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nameof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HFReasoner&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="n"&gt;MessageId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;messageId&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;await&lt;/span&gt; &lt;span class="n"&gt;completion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetChatCompletions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dialogs&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v3061/" rel="noopener noreferrer"&gt;V3061&lt;/a&gt;. Parameter 'dialogs' is always rewritten in method body before being used. &lt;a href="https://github.com/SciSharp/BotSharp/blob/b52cbf57f05a71a59d63b7e9f5922952a75b3ba8/src/Infrastructure/BotSharp.Core/Routing/Reasoning/HFReasoner.cs#L45" rel="noopener noreferrer"&gt;HFReasoner.cs 45&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;GetNextInstruction&lt;/code&gt; method takes a &lt;code&gt;dialogs&lt;/code&gt; collection as a parameter, but instead of adding to it, the method completely replaces the collection with a new, empty template. &lt;/p&gt;

&lt;p&gt;The parameter most likely stories some conversation context needed to generate a relevant response. Overwriting the variable wipes that context clean right before the request goes to &lt;code&gt;GetChatCompletions&lt;/code&gt;, which can noticeably hurt the quality of the response.&lt;/p&gt;

&lt;p&gt;The fix is straightforward. Add the new data with &lt;code&gt;Add&lt;/code&gt; or, if necessary, leave the &lt;code&gt;dialogs&lt;/code&gt; collection untouched, or build a new collection based on &lt;code&gt;dialogs&lt;/code&gt; with the extra element added in.&lt;/p&gt;

&lt;h3&gt;
  
  
  A copy-pasted condition
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="nf"&gt;Make_Payment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Description&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"order number"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;Required&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;order_number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Description&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"total amount"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;Required&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;total_amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order_number&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;McpException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Missing required argument 'order_number'"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order_number&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;McpException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Missing required argument 'total_amount'"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v3021/" rel="noopener noreferrer"&gt;V3021&lt;/a&gt;. There are two 'if' statements with identical conditional expressions. The first 'if' statement contains method return. This means that the second 'if' statement is senseless &lt;a href="https://github.com/SciSharp/BotSharp/blob/b52cbf57f05a71a59d63b7e9f5922952a75b3ba8/tests/BotSharp.Plugin.PizzaBot/McpServerTools/MakePaymentTool.cs#L11" rel="noopener noreferrer"&gt;MakePaymentTool.cs 11&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This one comes down to careless copying. The method is meant to check two required parameters, but since both &lt;code&gt;if&lt;/code&gt; conditions are identical, &lt;code&gt;order_number&lt;/code&gt; gets validated twice, while the second argument never gets checked at all.&lt;/p&gt;

&lt;p&gt;The exception text in the second block gives away the original intent, it was supposed to check &lt;code&gt;total_amount&lt;/code&gt;. Bugs like this slip right past a quick read, but static analysis catches them immediately.&lt;/p&gt;

&lt;h3&gt;
  
  
  A misunderstanding of operator precedence
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;RoleDialogModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;OnResponsedDone&lt;/span&gt;&lt;span class="p"&gt;(....)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;TokenStatsModel&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;....&lt;/span&gt;
    &lt;span class="n"&gt;TextInputTokens&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="n"&gt;inputTokenDetails&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
                      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextTokens&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;  &lt;span class="n"&gt;inputTokenDetails&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
                                         &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CachedTokenDetails&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
                                         &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextTokens&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;....&lt;/span&gt;

    &lt;span class="n"&gt;AudioInputTokens&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="n"&gt;inputTokenDetails&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
                       &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AudioTokens&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;  &lt;span class="n"&gt;inputTokenDetails&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
                                           &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CachedTokenDetails&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
                                           &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AudioTokens&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PVS-Studio warning:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/docs/warnings/v3123/" rel="noopener noreferrer"&gt;V3123&lt;/a&gt;. Perhaps the '??' operator works in a different way than it was expected. Its priority is lower than priority of other operators in its left part. &lt;a href="https://github.com/SciSharp/BotSharp/blob/b52cbf57f05a71a59d63b7e9f5922952a75b3ba8/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs#L542" rel="noopener noreferrer"&gt;RealTimeCompletionProvider.cs 542&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/docs/warnings/v3123/" rel="noopener noreferrer"&gt;V3123&lt;/a&gt;. Perhaps the '??' operator works in a different way than it was expected. Its priority is lower than priority of other operators in its left part. &lt;a href="https://github.com/SciSharp/BotSharp/blob/b52cbf57f05a71a59d63b7e9f5922952a75b3ba8/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs#L544" rel="noopener noreferrer"&gt;RealTimeCompletionProvider.cs 544&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This code reads as perfectly logical to a human, but the compiler sees it differently.&lt;/p&gt;

&lt;p&gt;The developer attempted to calculate a difference, with each operand guarded against &lt;code&gt;null&lt;/code&gt; by the &lt;code&gt;??&lt;/code&gt; operator. But the subtraction operator &lt;code&gt;-&lt;/code&gt; has a higher precedence than the &lt;code&gt;??&lt;/code&gt; null-coalescing operator, so instead of the intended &lt;code&gt;(A ?? 0) - (B ?? 0)&lt;/code&gt; what actually gets evaluated is &lt;code&gt;A ?? ((0 - B) ?? 0)&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;To get the intended behavior, the expressions around &lt;code&gt;??&lt;/code&gt; need to be explicitly wrapped in parentheses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputTokenDetails&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextTokens&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;inputTokenDetails&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
                                         &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CachedTokenDetails&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
                                         &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextTokens&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Potential null dereference
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Issue 1&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;RoleDialogModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;GetChatCompletions&lt;/span&gt;&lt;span class="p"&gt;(....)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;toolcall&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FirstOrDefault&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
                         &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;
                         &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tool_calls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FirstOrDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="n"&gt;responseMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;RoleDialogModel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;AgentRole&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Function&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;JsonSerializer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Serialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;toolcall&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v3146/" rel="noopener noreferrer"&gt;V3146&lt;/a&gt;. Possible null dereference of 'toolcall'. The 'FirstOrDefault' can return default null value. &lt;a href="https://github.com/SciSharp/BotSharp/blob/b52cbf57f05a71a59d63b7e9f5922952a75b3ba8/src/Plugins/BotSharp.Plugin.MetaGLM/Providers/ChatCompletionProvider.cs#L62" rel="noopener noreferrer"&gt;ChatCompletionProvider.cs 62&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the &lt;code&gt;toolcall&lt;/code&gt; variable gets its value from a call chain that uses the &lt;code&gt;FirstOrDefault&lt;/code&gt; method twice. &lt;/p&gt;

&lt;p&gt;The developer took every precaution in that chain, so if either collection turns out empty, &lt;code&gt;toolcall&lt;/code&gt; ends up as &lt;code&gt;null&lt;/code&gt; without throwing anything. &lt;/p&gt;

&lt;p&gt;The problem shows up right after, inside &lt;code&gt;JsonSerializer.Serialize&lt;/code&gt;, where the variable gets dereferenced with no check beforehand. Sooner or later that throws a &lt;code&gt;NullReferenceException&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Issue 2&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;BrowserActionResult&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;InputUserText&lt;/span&gt;&lt;span class="p"&gt;(....)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="n"&gt;locator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;actionParams&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ContextId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;htmlElementContextOut&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;await&lt;/span&gt; &lt;span class="n"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CountAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v3080/" rel="noopener noreferrer"&gt;V3080&lt;/a&gt;. Possible null dereference. Consider inspecting 'locator'. &lt;a href="https://github.com/SciSharp/BotSharp/blob/b52cbf57f05a71a59d63b7e9f5922952a75b3ba8/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.InputUserText.cs#L46" rel="noopener noreferrer"&gt;PlaywrightWebDriver.InputUserText.cs 46&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The analyzer flags another potential &lt;code&gt;null&lt;/code&gt; dereference, this time in &lt;code&gt;locator.CountAsync()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The declaration of the &lt;code&gt;Locator&lt;/code&gt; method explains why:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;ILocator&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;Locator&lt;/span&gt;&lt;span class="p"&gt;(....)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IsNullOrEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ElementName&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;....&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LogError&lt;/span&gt;&lt;span class="p"&gt;(....);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LogError&lt;/span&gt;&lt;span class="p"&gt;(....);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LogError&lt;/span&gt;&lt;span class="p"&gt;(....);&lt;/span&gt;
       &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are three separate paths where this method returns &lt;code&gt;null&lt;/code&gt;. Yet in the code the analyzer points to, that return value never gets checked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Issue 3&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;RoutableAgent&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;GetRoutableAgents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;profiles&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;routableAgents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;profiles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Count&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;profiles&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;profiles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Count&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;....&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v3095/" rel="noopener noreferrer"&gt;V3095&lt;/a&gt;. The 'profiles' object was used before it was verified against null. Check lines: 131, 137. &lt;a href="https://github.com/SciSharp/BotSharp/blob/b52cbf57f05a71a59d63b7e9f5922952a75b3ba8/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs#L131" rel="noopener noreferrer"&gt;RoutingService.cs 131&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This one comes down to a validation order problem. The developer planned for &lt;code&gt;profiles&lt;/code&gt; possibly being uninitialized and added a check for it in the &lt;code&gt;else if&lt;/code&gt; block. But that check comes too late, the &lt;code&gt;if&lt;/code&gt; statement above it already calls &lt;code&gt;profiles.Count&lt;/code&gt;. Swapping the two blocks fixes the logic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope this tour through the BotSharp source code was useful, and hopefully a bit entertaining too. Defects like these, an unclear operator precedence, a forgotten &lt;code&gt;case&lt;/code&gt; in a &lt;code&gt;switch&lt;/code&gt; statement, a lost argument value, blend right into large codebases. Finding them by hand in a massive project is a lot harder than it sounds, and that's exactly where static analysis earns its keep.&lt;/p&gt;

&lt;p&gt;If this article has you wanting to check your own project, you can &lt;a href="https://pvs-studio.com/en/pvs-studio/try-free/?utm_source=website&amp;amp;utm_medium=devto&amp;amp;utm_campaign=article&amp;amp;utm_content=1391" rel="noopener noreferrer"&gt;try the analyzer free&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;See you in the next articles!&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>ai</category>
      <category>programming</category>
    </item>
    <item>
      <title>Game++. Part 1.4: Game engine architectures</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Fri, 03 Jul 2026 14:38:04 +0000</pubDate>
      <link>https://dev.to/pvsdev/game-part-14-game-engine-architectures-43i6</link>
      <guid>https://dev.to/pvsdev/game-part-14-game-engine-architectures-43i6</guid>
      <description>&lt;p&gt;This book offers insights into C++, including algorithms and practices in game development, explores strengths and weaknesses of the language, its established workflows, and hands-on solutions. C++ continues to dominate the game development industry today thanks to its combination of high performance, flexibility, and extensive low-level control capabilities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjqth864ltofwmq8vs88u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjqth864ltofwmq8vs88u.png" alt=" " width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CryEngine (Microkernel Architecture)
&lt;/h2&gt;

&lt;p&gt;In the early 2000s, as developers sought ways to create more realistic and immersive game worlds, a unique game engine emerged, offering a completely new approach to architecture. CryEngine, developed by the German studio Crytek, revolutionized the industry with its stunning graphics and cutting-edge microkernel architecture. &lt;/p&gt;

&lt;p&gt;It all started with a tech demo called "X-Isle: Dinosaur Island." Built by a rather small team, the demo turned heads among publishers and developers alike. Back then, most game engines relied on a monolithic architecture with tightly coupled components, but the Yerli brothers (Avni, Faruk, and Cevat Yerli) had a different vision. Inspired by the design of the QNX operating system, they applied the principles of microkernel architecture to a game project. This laid the foundation for an engine that would later become one of the most technologically advanced of its time. &lt;/p&gt;

&lt;p&gt;Investors and studios put their faith in this approach, in which CryEngine isolates only critical functions in the central core, while the remaining components run as separate modules. Such modularity enabled developers to swap out components without destabilizing the whole system. Some implementations took it further, allowing individual logic modules and dynamic libraries to be reloaded at runtime, making it possible to update NPC behavior and fix logic bugs without restarting the game—only truly critical errors would cause a crash. Even then, a fallback handler could swap in the default module, reconnect the failed components, and let the session continue. This architecture also made it practical to create new features, as well as debug and optimize subsystems, without having to rebuild the entire engine. The brothers pushed the idea of supporting multiple genres on a single technology base, but it didn't quite work out, leaving CryEngine with the "best engine for FPS" reputation. &lt;/p&gt;

&lt;p&gt;The first commercial game to demonstrate the power of the microkernel approach was Far Cry (2004), which impressed players with its vast open areas, long draw distances, and realistic vegetation, as well as a world that responded dynamically to the player's actions. The second version of CryEngine, used in Crysis (2007), became the technical benchmark for the new generation of graphics hardware, setting the standard for rendering performance; meanwhile, the phrase "But can it run Crysis?" became a meme among gamers. &lt;/p&gt;

&lt;p&gt;The microkernel approach behind the engine left a mark on the entire game development industry, pushing concepts like scalability, fault tolerance, and cross-platform adaptability into the mainstream. Other engines began adopting similar practices. In fact, after the release of Crysis 2, scalability and adaptability became standard expectations in engine development. &lt;/p&gt;

&lt;p&gt;CryEngine, like all major game engines at the time, was cross-platform from release. The renderer supported OpenGL and DirectX 8/9 and was designed for open environments; a single game level could contain areas spanning up to three square kilometers. The physics system was built entirely in-house, yet that never compromised its quality. It handled rigid bodies, fluids, vehicles, cloth simulation, soft-body objects, and ragdoll physics—in every respect, the technology reached an exceptionally high standard for a proprietary solution.&lt;/p&gt;

&lt;p&gt;Its inverse kinematics technology allowed layering multiple animations onto a single model at once, which made character movement look far more natural. A module written in Lua, rather than C++, handled the NPCs' AI. The scripts could be changed without recompiling, a rare feature at the time. CryEngine also gave us Far Cry and its many expansions, as well as the MMORPG AION. NCSoft licensed CryEngine for AION, although the company later reworked it extensively to fit the demands of multiplayer online games. &lt;/p&gt;

&lt;p&gt;In 2004, following the release of Far Cry, the shader module gained support for Shader Model 3.0, and the engine was updated to 1.2. Shaders unlocked a long list of visual effects: per-pixel lighting, bump-mapped reflections, refraction, smoke, animated textures, transparent computer screens, see-through surfaces, and bullet decals. One particularly notable feature was the fog rendering, which looked far more realistic than what competing engines of that era could pull off. &lt;/p&gt;

&lt;p&gt;In March 2006, Ubisoft acquired full rights to the Far Cry franchise, along with a license to CryEngine. This covered the entire IP, including the trademark, logo, characters, story, and setting, as well as exclusive rights to the source code and the underlying technology—meaning the original team could no longer use any of the old code to develop a new engine. &lt;/p&gt;

&lt;p&gt;After Crytek released the final patches for Far Cry, development of the technology split into two separate paths. Ubisoft, now holding the Far Cry franchise and a licensed copy of the engine's source code, went on to develop its own version for Far Cry Instincts and Far Cry Instincts: Evolution on Xbox, Far Cry Instincts: Predator on Xbox 360, and Far Cry Vengeance for the Nintendo Wii. According to Louis-Pierre Farand, lead producer on Far Cry 2, the resulting Dunia Engine retained only 2–3% of the original CryEngine's source code (Pic. 2.7). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4sp03pkv9s84gkhuxkbf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4sp03pkv9s84gkhuxkbf.png" alt=" " width="800" height="589"&gt;&lt;/a&gt;&lt;br&gt;
Picture 2.7&lt;/p&gt;

&lt;p&gt;In turn, Crytek's developers continued developing their own technology platform and created a new engine, CryEngine 2, which marked the next step in its evolution and was fully independent of Ubisoft. Like its predecessor, the engine was written in C++, but unlike the original, it did not aim for cross-platform support. It targeted a single platform: Microsoft Windows with DirectX. At the time of its release, CryEngine 2 ranked among the most technologically advanced and photorealistic game engines on the market, setting new standards for rendering, physics, and dynamic environments. However, its demanding hardware requirements and dependence on Windows and DirectX limited its audience to owners of high-end gaming PCs. &lt;/p&gt;

&lt;p&gt;The engine kept every feature from the previous version and even improved most of them. CryEngine 2 handled massive open environments just as effectively, while a new asset streaming system allowed levels to load dynamically as the player progressed. Crytek was also among the first studios to ship a 64-bit build of a game. Because game worlds had grown considerably since Far Cry, rendering them took far more system resources, making 32-bit systems inadequate. &lt;/p&gt;

&lt;p&gt;The microkernel architecture remained intact as well: the compiled engine was split into separate DLLs, with each component packaged as its own library and loaded on demand during gameplay. This meant developers could swap out or modify individual pieces without touching the rest of the engine.&lt;/p&gt;

&lt;p&gt;CryPhysics, the new in-house physics engine Crytek built for this version, was designed for multithreading from the start and fully integrated into CryEngine 2. It opened the door to far more extensive physics interactions and allowed the engine to apply physics simulation to nearly every object in a level, including trees and vegetation, so they reacted realistically to gravity, wind, explosions, and collisions.&lt;/p&gt;

&lt;p&gt;As with the previous version, the transition to CryEngine 3 came with friction, both within the team and among executives. A completely different team took over development, so the results were a mixed bag: some parts impressed, others fell flat. CryEngine 3 was officially announced on March 11, 2009, and released that same year on October 14. The first game to use the new engine was the first-person shooter Crysis 2.&lt;/p&gt;

&lt;p&gt;The engine was originally developed with DirectX 11 support, but Crysis 2 shipped without it—as well as DirectX 10—until a patch came out. The likely reason was Crytek's push to turn Crysis 2 into a cross-platform release. One major drawback of staying PC-exclusive was piracy: every legitimate copy sold was reportedly matched by about ten pirated downloads. As a result, the studio shifted its focus toward consoles.&lt;/p&gt;

&lt;p&gt;Modern versions of CryEngine continue to build on the ideas behind its microkernel architecture while gradually expanding the use of AI in both tooling and graphics. The philosophy established by the Yerli brothers left a lasting mark on the game industry, proving that modularity, flexibility, and scalability can coexist with high performance.&lt;/p&gt;

&lt;p&gt;A related branch of the technology now lives on as an open-source engine, &lt;a href="https://github.com/o3de/o3de" rel="noopener noreferrer"&gt;O3DE&lt;/a&gt;, which evolved from Amazon Lumberyard. Lumberyard was based on a 2015 version of CryEngine, whose source code is available &lt;a href="https://github.com/CRYTEK/CRYENGINE_ReadMe" rel="noopener noreferrer"&gt;separately&lt;/a&gt;. Amazon licensed the CryEngine source code, refactored and reorganized the project, and released it on GitHub as Lumberyard under a proprietary license. Later, the company handed the project over to the community as O3DE, making it freely available as open source. By the time it became open source, more than $50 million had reportedly been invested in the technology—some estimates place that figure above the development costs of Unity and Unreal Engine, or at least on a comparable level. The original modular architecture now takes the form of independent Gem components that developers can freely add to or remove from a project (Pic. 2.8).&lt;/p&gt;

&lt;p&gt;Today, O3DE remains under active development. Although the engine offers a rich feature set, it has yet to achieve the same level of adoption as Unreal or Unity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffgu7rjtsg4f3rjj4fo4q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffgu7rjtsg4f3rjj4fo4q.png" alt=" " width="561" height="526"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picture N2.8&lt;/p&gt;
&lt;h2&gt;
  
  
  Dagor (Data-driven Architecture)
&lt;/h2&gt;

&lt;p&gt;Among many well-known game engines, many of which trace back to the United States, there are a few notable exceptions from Eastern Europe that have shaped the industry in their own way. One such example is Dagor Engine, developed by Gaijin Entertainment. The engine stands out not only for its technical features and its ability to run on virtually any platform with a GPU and at least some kind of CPU, but also for its distinctive architecture built around data-driven design principles. Today, it's publicly available, so anyone can &lt;a href="https://github.com/GaijinEntertainment/DagorEngine" rel="noopener noreferrer"&gt;explore what's under the hood&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The engine's history goes back to the early 2000s, when an in-house game development tool gained wider recognition after the release of IL-2 Sturmovik: Birds of Prey (2009). The game showed that the engine could handle complex physics models, render realistic visual effects, and put data-driven design to real use.&lt;/p&gt;

&lt;p&gt;Data-driven architecture is an approach where application logic comes mainly from data rather than being hard-coded in the source. For game engines, that means most elements of the game world—objects and their behavior included—are described in data files such as JSON, XML, or other structured formats. The engine interprets these files at runtime, which brings a few clear advantages. Data and code stay separate. Objects and their properties are defined declaratively—describing what should happen rather than how to implement it. And configuration becomes dynamic, letting developers make changes without recompiling or even restarting the game. Put together, these traits naturally evolve into a component-based system that's defined and configured entirely through data.&lt;/p&gt;

&lt;p&gt;In traditional engines, changing game object behavior often requires writing or modifying code, recompiling it, and then testing the result. Here, game designers and artists can adjust object parameters, effects, and even core behavior simply by editing data files—effectively making changes on the fly. During an internal tournament for one of the studio's games, the admins spawned random level objects mid-game by simply dropping blk files (Dagor's equivalent of JSON) into the level folder. Cars, weapons, fridges, and a couple of tanks started appearing out of nowhere for the players.&lt;/p&gt;

&lt;p&gt;Data-driven architecture pairs naturally with a component-based approach to designing game objects. Over time, developers start thinking this way by default and can't imagine working otherwise. In Dagor Engine, each object can be built from a set of components, with each one handling a specific functional aspect. This makes it easy to create new object variations just by combining and configuring existing components. Once again, all of this happens on the fly, without recompiling the engine and often without even restarting the game.&lt;/p&gt;

&lt;p&gt;Contrary to the common belief that runtime data interpretation slows games down, a well-designed data-driven architecture can still deliver high performance. The evidence is indirect but visible: the company's games run at acceptable frame rates on mobile devices and the Nintendo Switch, neither of which is exactly known for raw power.&lt;/p&gt;

&lt;p&gt;The resource system is a cornerstone of the data-driven architecture. The engine organizes all game data into a hierarchical structure of configs, each with a unique identifier and loadable on demand. In Dagor Engine, the code might look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;vehicles&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;tanks&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blk&lt;/span&gt; &lt;span class="n"&gt;textures&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;span class="n"&gt;diffuse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dds&lt;/span&gt; &lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dds&lt;/span&gt; &lt;span class="n"&gt;specular&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dds&lt;/span&gt;
&lt;span class="n"&gt;weapons&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blk&lt;/span&gt; &lt;span class="n"&gt;collision&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blk&lt;/span&gt;


&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;weapons&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;guns&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;85&lt;/span&gt;&lt;span class="n"&gt;mm_zis&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;ballistics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blk&lt;/span&gt; &lt;span class="n"&gt;Visual_effects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blk&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The *.blk files are a special structured data format used in the engine. While similar to JSON in function, they are optimized for fast loading, efficient processing, and overriding of sections and properties. When loading, the game can pull in values to override object properties from another config. It typically looks something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;visual_effects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blk&lt;/span&gt; &lt;span class="n"&gt;graphics&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;rendinstDistMul:&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="n"&gt;grassRadiusMul&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;visual_effects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="n"&gt;blk&lt;/span&gt; &lt;span class="n"&gt;graphics&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;override&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;rendinstDistMul&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.8&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final configuration ends up with &lt;code&gt;rendinstDistMul = 0.8&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Despite all its advantages, data-driven architecture also comes with serious drawbacks. The first is debugging complexity. Since behavior comes from data rather than code, debugging takes a lot more effort and usually needs specialized tools to track how data changes ripple through the system. In real projects, this often means maintaining separate visual debugging tools tailored to a specific engine.&lt;/p&gt;

&lt;p&gt;The second drawback is interpretation overhead. However efficiently the engine optimizes data processing, runtime interpretation still introduces additional costs compared to hard-coded logic.&lt;/p&gt;

&lt;p&gt;Pic. 2.9 shows the systems developers can configure just by modifying scripts, without rebuilding the entire engine—and, as you can see, that covers almost the entire engine.&lt;/p&gt;

&lt;h2&gt;
  
  
  X-Ray Engine (Monolith Architecture)
&lt;/h2&gt;

&lt;p&gt;The history of the video game industry is full of technologies that arrived ahead of their time. One such example is the X-Ray Engine, created by programmers Alexander Maksimchuk and Oles Shishkovtsov for the S.T.A.L.K.E.R. series. The game was originally going to be about robots on some unknown planet filled with anomalies and lasers. At some point the team realized they did not need to invent either the planet or the robots—the perfect anomalous zone with the perfect atmosphere already existed just a three-hour drive from their office. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3uizwyrhffnin1tzrpmh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3uizwyrhffnin1tzrpmh.png" alt=" " width="800" height="977"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picture N2.9&lt;/p&gt;

&lt;p&gt;First shown back in 2001, the engine went on to become the foundation for one of the most immersive gaming worlds ever created. Its graphics held up impressively well for the time. The engine could render up to four million polygons on screen, far beyond what even many late-2000s games could handle. It managed large-scale environments just as well, whether enclosed interiors or open areas reaching up to two square kilometers. On top of that, it ran a full dynamic day-night cycle with lighting changes, along with weather effects like rain, wind, and fog. The dynamic lighting in particular still impresses, producing memorable shots and an atmosphere that's hard to forget even now.&lt;/p&gt;

&lt;p&gt;For physics, X-Ray relied on the open-source Open Dynamics Engine (ODE), also released in 2001. It handled rigid-body dynamics and collision detection, and worked well for simulating vehicles, creatures, and objects in a dynamic environment. On paper, the engine's integration system was stable enough that physics shouldn't have broken down without reason. In reality, players of the first S.T.A.L.K.E.R. game soon got very familiar with all kinds of physics anomalies—from flying bodies to bizarre object behavior. Those quirks eventually turned into one of the series' signature traits, inspiring memes and funny clips. Well, it simply fit the nature of the Zone—after all, anomalies are part of the setting.&lt;/p&gt;

&lt;p&gt;This engine is a textbook example of monolithic architecture (not to be confused with a unitary one). It is divided into separate parts, but those parts are tightly bound together rather than loosely coupled. Unlike systems where components operate relatively independently, X-Ray Engine functions as a tightly integrated whole, with all components deeply interconnected.&lt;/p&gt;

&lt;p&gt;Monolithic architecture (Pic. 2.10) brings both clear advantages and serious drawbacks. Tight integration across graphics, physics, and AI—and the ability to build gameplay mechanics directly off how components interact—enabled developers to use and plan resources more efficiently through custom allocators, object packing, fast message queues, and similar techniques. With no abstraction layers standing between components, interaction stayed direct and fast, which mattered a lot on the hardware available at the time. Developers could precisely control memory usage and CPU time, which proved critical for a project this demanding.&lt;/p&gt;

&lt;p&gt;This unified structure also meant the engine, the game world, development tools, and subsystems could share one coherent vision, with everything working together naturally. Removing or isolating any individual part would inevitably reduce functionality and hurt overall performance.&lt;/p&gt;

&lt;p&gt;However, the same characteristics that boost performance can also limit scalability, make individual components harder to update, and introduce various challenges, especially on multicore systems. As the system grows, maintaining it and fixing bugs becomes exponentially more difficult, since changes in one part often ripple through neighboring subsystems.&lt;/p&gt;

&lt;p&gt;In fact, complexity ended up being the biggest technical issue of the X-Ray Engine. Beyond the random crashes familiar to every fan—hello, "bug trap"—the engine also suffered from micro-freezes and brief stutters that showed up across every game in the S.T.A.L.K.E.R series. They were especially bad in Shadow of Chernobyl, where, in extreme cases, the game could turn into a slideshow while running at a normal frame rate. The root cause was architectural: the engine relied heavily on a single CPU core, a limitation that only became more painful as multicore systems took over.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2jnm5fqv6zg6c20ik5k9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2jnm5fqv6zg6c20ik5k9.png" alt=" " width="709" height="872"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picture 2.10&lt;/p&gt;

&lt;p&gt;The last official version of the engine is X-Ray Engine 1.6.02, used in Call of Pripyat. The fan community didn't stop there, though. Enthusiasts kept refining the technology, creating unofficial engine versions that fixed many critical issues, introduced new features, and—most importantly—added support for multicore processors and multithreading.&lt;/p&gt;

&lt;p&gt;Technical problems aside, the engine remains an important milestone in the history of game development. Its strengths—dynamic lighting, advanced physics, and the A-Life simulation system—were years ahead of their time and gave players plenty of standout moments. And perhaps this monolith really did make someone's dream game a reality.&lt;/p&gt;

&lt;p&gt;Monolithic architecture—with all its strengths and weaknesses, and above all when applied deliberately—serves as an excellent example of a particular approach to building game engines. It also offers a valuable lesson for the industry as a whole. The engine's core concepts and many of the practices developed around it would later inform the 4A Engine, built by former members of the team for the Metro series.&lt;/p&gt;

&lt;h2&gt;
  
  
  Godot (Modules/Services Architecture)
&lt;/h2&gt;

&lt;p&gt;From the outside, the game development industry may seem to advance at a rapid pace: new rendering technologies, new approaches to rigging, better-looking models, voice acting, and the growing use of AI for animation. Under the hood, however, all these things still rely on well-tested, established solutions that are extremely difficult to replace or change in any fundamental way. I would even argue that, outside conference talks, game development remains highly conservative. Big studios avoid risks, while smaller teams often lack the time and resources to take them, even when they'd like to. Real architectural innovation is rare. Against this backdrop, the adoption of concepts from the web—as seen with the Godot engine and microservices architecture—becomes particularly interesting.&lt;/p&gt;

&lt;p&gt;Most architectural styles receive their names once communities or conference speakers notice a recurring pattern and start shaping it into something more defined—there is no secret council of architects deciding what the next major trend will be. More often, developers independently arrive at similar solutions as an engine's ecosystem evolves and new challenges emerge. The approaches that prove most effective at adapting to change and leveraging it eventually become recognized architectural patterns that others follow. Microservices stand out here, because when the concept first emerged, no game engine or game actually followed those principles. In fact, the term gained recognition through the article "Microservices" by Martin Fowler and James Lewis, published in 2014. In that article, the authors laid out the common traits of this relatively new architectural style. Looking at Godot, I see many of those same ideas at work. At its core, the microservices approach breaks a complex system into numerous small, autonomous services, each providing a specific set of features.&lt;/p&gt;

&lt;p&gt;In the context of game development with Godot, this idea evolves into a microservice-like architecture where the game no longer exists as a monolithic mass of code but as a system of components that talk to each other. Physics, AI, UI, and the audio system—each of these elements can exist as a separate module with a clearly defined way of interacting with the rest. I would not call this approach perfect, but it does allow developers to focus on individual aspects of the game without constantly worrying about how a change might affect the rest of the project.&lt;/p&gt;

&lt;p&gt;Godot first appeared in 2014 and has since won over many developers thanks to its simplicity and reliability. Its name comes from the character who never arrives in Samuel Beckett's play Waiting for Godot. What sets Godot apart is how it organizes game logic through a system of nodes and scenes. Imagine a construction set where every piece of the game—from a character to an interface—is a separate building block that snaps easily to others. Although Godot wasn't originally designed with microservices in mind, its node-based architecture and modularity ended up fitting that philosophy surprisingly well. The result was an architecture where different components can be developed almost entirely independently of each other.&lt;/p&gt;

&lt;p&gt;Godot's signal mechanism provides a particularly elegant way to connect these components. Imagine a player picking up an item: the inventory system emits a signal, and other systems can react to it. The UI updates, the achievement system logs progress toward whatever is being collected, and a special abilities system recalculates character stats. None of these systems needs to know how the others work—or, in some cases, even that they exist at all.&lt;/p&gt;

&lt;p&gt;In fact, the engine's core philosophy revolves around adding new features by creating new modules rather than modifying existing ones. Developers can reuse component modules across different projects, and if a module has a bug, it is less likely to affect the entire game. Of course, no game can be broken down into modules indefinitely, but this approach at least cuts the chances of the entire thing crashing due to a single faulty component.&lt;/p&gt;

&lt;p&gt;That said, this architecture is no silver bullet—though for smaller projects it often works exceptionally well: you snap together a set of component modules, wire up their signals, and—voilà—everything comes together and works as intended. As a project grows, though, the sheer number of interactions and gameplay systems tends to introduce excessive complexity and slow things down. The signal system can become a bottleneck, while modules may start competing for updates. The real takeaway is that micro-modules only make sense where they provide a clear benefit. For example, separating game logic from visual presentation almost always pays off. On the other hand, splitting tightly coupled mechanics into independent services or modules often leads to unnecessary complexity later on.&lt;/p&gt;

&lt;p&gt;Another important distinction is that, unlike traditional microservices in web development—which run as separate processes or even on different machines—all game components operate within the same process (or a small number of processes). This sidesteps a lot of communication and synchronization headaches typical of classical microservice systems, the kind of problems that would only get in the way at such a small scale.&lt;/p&gt;

&lt;p&gt;Even so, this approach has gained a dedicated following: more than a dozen relatively large games shipped on Godot in 2024 alone. That may not sound impressive compared to the thousands released on Unreal Engine or Unity, but it is a significant achievement for a project maintained primarily by a handful of core developers and its community.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Author: Sergei Kushnirenko&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sergei has over 20-year experience in coding and game development. He graduated from ITMO National Research University and began his career developing software for naval simulators, navigation systems, and network solutions. For the past fifteen years, Sergei has specialized in game development: at Electronic Arts, he worked on optimizing The Sims and SimCity BuildIt, and at Gaijin Entertainment, Sergei headed up the porting of games to the Nintendo Switch and Apple TV platforms. Sergei actively participates in open-source projects, including the ImSpinner library and the Pharaoh (1999) game restoration project.&lt;/p&gt;

&lt;h2&gt;
  
  
  All parts
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/1361/" rel="noopener noreferrer"&gt;Game++. Part 1.1: Game engine architectures&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/1375/" rel="noopener noreferrer"&gt;Game++. Part 1.2: Game engine architectures&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/1384/" rel="noopener noreferrer"&gt;Game++. Part 1.3: Game engine architectures&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>gamedev</category>
      <category>programming</category>
      <category>software</category>
    </item>
    <item>
      <title>Code slicing: What lies inside OrcaSlicer</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Tue, 30 Jun 2026 14:19:06 +0000</pubDate>
      <link>https://dev.to/pvsdev/code-slicing-what-lies-inside-orcaslicer-19pn</link>
      <guid>https://dev.to/pvsdev/code-slicing-what-lies-inside-orcaslicer-19pn</guid>
      <description>&lt;p&gt;How can you avoid overlooking dangerous code parts during reviews? You can use static analysis tools. Let's take as an example OrcaSlicer, a popular slicing software designed to prepare 3D models for printing. We'll take a peek under its hood and see what surprises await us.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft8s6gvqcynm8w5ybi9e8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft8s6gvqcynm8w5ybi9e8.png" alt="1389_OrcaSlicer/image1.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  About the project
&lt;/h2&gt;

&lt;p&gt;There's a cool project on GitHub that helps prepare 3D models for printing. It can convert a 3D model into machine instructions for creating an object layer by layer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/OrcaSlicer/OrcaSlicer" rel="noopener noreferrer"&gt;OrcaSlicer&lt;/a&gt; is one of the most popular free open-source slicers. The project is quite large, and its primary development language is C++, which is exactly why it caught my attention. Today, let's take a look under the hood and explore some of the code's highlights.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;. The purpose of this content is to promote static analysis technology, not to offend the authors of OrcaSlicer.&lt;/p&gt;

&lt;p&gt;The article simply shows that even functioning projects can contain bugs. Developers may overlook issues during code reviews or testing, and they accumulate over the years, which can ultimately lead to defects in the product. However, using additional tools, such as static analyzers, helps developers detect bugs before they reach production.&lt;/p&gt;

&lt;p&gt;If you still doubt the value of such tools, I recommend reading the article "&lt;a href="https://pvs-studio.com/en/blog/posts/0687/" rel="noopener noreferrer"&gt;Why you should choose the PVS-Studio static analyzer to integrate into your development process&lt;/a&gt;."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Let's dive in
&lt;/h2&gt;

&lt;p&gt;I analyzed this project &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/commit/a167702038496b97e8495cc79f0c62660063ac87" rel="noopener noreferrer"&gt;commit&lt;/a&gt; using &lt;a href="https://pvs-studio.com/en/" rel="noopener noreferrer"&gt;PVS-Studio&lt;/a&gt; plugin for Visual Studio 2022. The article doesn't cover every warning the analyzer issued, only the ones I found the most interesting.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note.&lt;/strong&gt; To improve readability, the code snippets have been formatted, and some have been hidden behind comments marked with &lt;code&gt;// ....&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Example N1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v655/" rel="noopener noreferrer"&gt;V655&lt;/a&gt; The strings were concatenated but are not utilized. Consider inspecting the 'message + "\n\nApplication will close."' expression. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/GUI_App.cpp#L7170" rel="noopener noreferrer"&gt;GUI_App.cpp 7170&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;GUI_App&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;load_language&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wxString&lt;/span&gt; &lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;initial&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;wxLocale&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;IsAvailable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;locale_language_info&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;Language&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Loading the language dictionary failed.&lt;/span&gt;
    &lt;span class="n"&gt;wxString&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;   &lt;span class="s"&gt;"Switching Orca Slicer to language "&lt;/span&gt;
                       &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;requested_language_code&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" failed."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cp"&gt;#if !defined(_WIN32) &amp;amp;&amp;amp; !defined(__APPLE__)
&lt;/span&gt;      &lt;span class="c1"&gt;// likely some linux system&lt;/span&gt;
      &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;You may need to reconfigure the missing locales, "&lt;/span&gt;
                 &lt;span class="s"&gt;" likely by running the &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s"&gt;locale-gen&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s"&gt; "&lt;/span&gt;
                 &lt;span class="s"&gt;"and &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s"&gt;dpkg-reconfigure locales&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s"&gt; commands.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cp"&gt;#endif
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;initial&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n\n&lt;/span&gt;&lt;span class="s"&gt;Application will close."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;              &lt;span class="c1"&gt;// &amp;lt;=&lt;/span&gt;
    &lt;span class="n"&gt;wxMessageBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Orca Slicer - Switching language failed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                 &lt;span class="n"&gt;wxOK&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;wxICON_ERROR&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;initial&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's a typo that developers missed during code review. The code uses &lt;code&gt;+&lt;/code&gt; instead of &lt;code&gt;+=&lt;/code&gt;, so the string literal never gets appended to the &lt;code&gt;message&lt;/code&gt; variable. The code compiles, but it makes no sense. This warning reminded me of an &lt;a href="https://pvs-studio.com/en/blog/posts/cpp/1119/#ID717E26CA54" rel="noopener noreferrer"&gt;error we caught in qbEngine&lt;/a&gt;, where devs forgot to add the &lt;code&gt;#&lt;/code&gt; character in the &lt;code&gt;#else&lt;/code&gt; macro.&lt;/p&gt;

&lt;p&gt;When looking at this code, one might think: "No way! I'd never write something like this." It's simply a mistake a human can do, though. This code has been in the project for four years, yet it still hasn't been fixed. At the same time, the fragment where the &lt;code&gt;message&lt;/code&gt; string is initialized was &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/commit/8168d0a4e088748dde3d843fd1aa77eed245f528#diff-8432157ace185a6e4c63a53f838d80cd1bbae25fdd3829b94a54fc5ecf5b6dabL6443-R6466" rel="noopener noreferrer"&gt;modified&lt;/a&gt; just a couple of months ago.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example N2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v1047/" rel="noopener noreferrer"&gt;V1047&lt;/a&gt; Lifetime of the lambda is greater than lifetime of the local variable 'do_stop' captured by reference. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/Jobs/FillBedJob.cpp#L250" rel="noopener noreferrer"&gt;FillBedJob.cpp 250&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;FillBedJob&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;process&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Ctl&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;ctl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;do_stop&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;on_packed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;do_stop&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ArrangePolygon&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;ap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;do_stop&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bed_idx&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;ap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;priority&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The lambda expression captures the &lt;code&gt;do_stop&lt;/code&gt; local variable by reference and then stores it in &lt;code&gt;params.on_packed&lt;/code&gt;. However, &lt;code&gt;do_stop&lt;/code&gt; is destroyed when the &lt;code&gt;process&lt;/code&gt; method exits because the lifetime of the local object ends. If the lambda runs after the member function returns, it will access a destroyed object, resulting in undefined behavior.&lt;/p&gt;

&lt;p&gt;Capturing by value would solve this issue, but the lambda modifies the &lt;code&gt;do_stop&lt;/code&gt; variable, so this approach won't work. Instead, &lt;code&gt;do_stop&lt;/code&gt; can be turned into a member of the &lt;code&gt;FillBedJob&lt;/code&gt; class.&lt;/p&gt;

&lt;p&gt;This pattern repeats two more times in the code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;V1047 Lifetime of the lambda is greater than lifetime of the local variable 'statustxt' captured by reference. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/Jobs/FillBedJob.cpp#L245" rel="noopener noreferrer"&gt;FillBedJob.cpp 245&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;V1047 Lifetime of the lambda is greater than lifetime of the local variable 'do_stop' captured by reference. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/Jobs/FillBedJob.cpp#L241" rel="noopener noreferrer"&gt;FillBedJob.cpp 241&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example N3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v768/" rel="noopener noreferrer"&gt;V768&lt;/a&gt; The enumeration constant 'roPortrait' is used as a variable of a Boolean-type. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/libslic3r/SLA/RasterBase.hpp#L81" rel="noopener noreferrer"&gt;RasterBase.hpp 81&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RasterBase&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;public:&lt;/span&gt;

  &lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="n"&gt;Orientation&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;roLandscape&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;roPortrait&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;Trafo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;mirror_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mirror_y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flipXY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="n"&gt;TMirroring&lt;/span&gt; &lt;span class="n"&gt;get_mirror&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; 
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;roPortrait&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;mirror_x&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;mirror_x&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mirror_y&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="c1"&gt;// &amp;lt;=&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The analyzer detected an enum value being used as the first operand in a ternary operator. The &lt;code&gt;roPortrait&lt;/code&gt; constant has a value of &lt;code&gt;1&lt;/code&gt;, so the condition is always true. Most likely, the developers should've used another variable here.&lt;/p&gt;

&lt;p&gt;Alternatively, an additional parameter may have been needed to compare it with &lt;code&gt;roPortrait&lt;/code&gt;, as done in the constructor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;  &lt;span class="n"&gt;Trafo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Orientation&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;roLandscape&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;TMirroring&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;mirror&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NoMirror&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// XY flipping implicitly does an X mirror&lt;/span&gt;
    &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;mirror_x&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;roPortrait&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;mirror&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;mirror&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;          &lt;span class="c1"&gt;// &amp;lt;=&lt;/span&gt;
    &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mirror_y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;mirror&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;// Makes raster origin to be top left corner&lt;/span&gt;
    &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flipXY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;roPortrait&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example N4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v781/" rel="noopener noreferrer"&gt;V781&lt;/a&gt; The value of the 'm_load_slot_index' variable is checked after it was used. Perhaps there is a mistake in program logic. Check lines: 2152, 2155. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/Widgets/AMSItem.cpp#L2152" rel="noopener noreferrer"&gt;AMSItem.cpp 2152&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;AMSRoadUpPart&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;doRender&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wxDC&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;dc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="n"&gt;dc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SetPen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wxPen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_get_diff_clr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;m_amsinfo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cans&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;m_load_slot_index&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;material_colour&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxPENSTYLE_SOLID&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m_amsinfo&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m_load_step&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;AMSPassRoadSTEP&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;AMS_ROAD_STEP_NONE&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m_amsinfo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cans&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;m_load_slot_index&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;m_load_slot_index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
      &lt;span class="n"&gt;BOOST_LOG_TRIVIAL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"up road render error"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These errors are especially intriguing because they seem impossible to make at first glance. The case may seem simple, but it's actually quite confusing. If we look through the &lt;a href="https://pvs-studio.com/en/blog/examples/v781/" rel="noopener noreferrer"&gt;list of issues&lt;/a&gt; the V781 diagnostic rule detected, we can see that even developers working on fairly large projects make these mistakes quite often.&lt;/p&gt;

&lt;p&gt;What's the problem, though? It's array index out of bounds. First, the &lt;code&gt;m_load_slot_index&lt;/code&gt; index is used to access an element of the &lt;code&gt;m_amsinfo.cans&lt;/code&gt; vector, only then it's checked whether the iterator is out of bounds or negative. The check exists, but it happens too late. We can fix the code by placing the check earlier or handling this case differently.&lt;/p&gt;

&lt;p&gt;The same warning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;V781 The value of the 'i' index is checked after it was used. Perhaps there is a mistake in program logic. ViewerImpl.cpp 56&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example N5&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v783/" rel="noopener noreferrer"&gt;V783&lt;/a&gt; Iterator 'it' is checked after it was used. Perhaps there is a mistake in program logic. Check lines: 3159, 3160. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/Selection.cpp#L3160" rel="noopener noreferrer"&gt;Selection.cpp 3160&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;Selection&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ensure_not_below_bed&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;is_any_volume&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;m_list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;GLVolume&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;m_volumes&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
      &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;pair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
        &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;make_pair&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;object_idx&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;instance_idx&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
      &lt;span class="n"&gt;InstancesToZMap&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;const_iterator&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;instances_max_z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;z_shift&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SINKING_MIN_Z_THRESHOLD&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;second&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;instances_max_z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;z_shift&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_volume_offset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_volume_offset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;z_shift&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This fragment contains another check that also appears after the iterator is used. The&lt;code&gt;it&lt;/code&gt; iterator is dereferenced to calculate &lt;code&gt;z_shift&lt;/code&gt;, and the next line contains a check whether it differs from the &lt;code&gt;end()&lt;/code&gt; iterator. If the element isn't found, dereferencing the resulting iterator leads to undefined behavior.&lt;/p&gt;

&lt;p&gt;The fixed code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;instances_max_z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;z_shift&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SINKING_MIN_Z_THRESHOLD&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;second&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z_shift&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_volume_offset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_volume_offset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;z_shift&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example N6&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warnings:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/docs/warnings/v595/" rel="noopener noreferrer"&gt;V595&lt;/a&gt; The 'part_plate' pointer was utilized before it was verified against nullptr. Check lines: 498, 525. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/ObjectDataViewModel.cpp#L498" rel="noopener noreferrer"&gt;ObjectDataViewModel.cpp 498&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/docs/warnings/v522/" rel="noopener noreferrer"&gt;V522&lt;/a&gt; Dereferencing of the null pointer 'part_plate' might take place. The null pointer is passed into 'AddPlate' function. Inspect the first argument. Check lines: 497, 535. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/ObjectDataViewModel.cpp#L497" rel="noopener noreferrer"&gt;ObjectDataViewModel.cpp 497&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;wxDataViewItem&lt;/span&gt; &lt;span class="n"&gt;ObjectDataViewModel&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;AddOutsidePlate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;refresh&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;wxDataViewItem&lt;/span&gt; &lt;span class="n"&gt;plate_item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;AddPlate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;nullptr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_L&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Outside"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;         &lt;span class="c1"&gt;// &amp;lt;=&lt;/span&gt;
  &lt;span class="n"&gt;m_plate_outside&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ObjectDataViewModelNode&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;plate_item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetID&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;plate_item&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// ....&lt;/span&gt;

&lt;span class="n"&gt;wxDataViewItem&lt;/span&gt; &lt;span class="n"&gt;ObjectDataViewModel&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;AddPlate&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PartPlate&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;part_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxString&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;refresh&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;int&lt;/span&gt;  &lt;span class="n"&gt;plate_idx&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;part_plate&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;part_plate&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;get_index&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// &amp;lt;= 1 &lt;/span&gt;
  &lt;span class="n"&gt;wxString&lt;/span&gt; &lt;span class="n"&gt;plate_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;empty&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;plate_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_L&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Plate"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;plate_name&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;wxString&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;" %d"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;plate_idx&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;part_plate&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;get_plate_name&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;empty&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;                          &lt;span class="c1"&gt;// &amp;lt;= 2&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;plate_name&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;wxString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;" ("&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;wxConvUTF8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;from_u8&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;part_plate&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;get_plate_name&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;wxString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;")"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;wxConvUTF8&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;obj_idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;obj_idx&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;m_objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;obj_idx&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;obj_node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m_objects&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;obj_idx&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;part_plate&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;part_plate&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;contain_instance_totally&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj_idx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)){&lt;/span&gt;&lt;span class="c1"&gt;// &amp;lt;= 3&lt;/span&gt;
      &lt;span class="n"&gt;ReparentObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;plate_node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;obj_node&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;plate_item&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a long snippet, so let's break it down step by step. The &lt;code&gt;AddOutsidePlate&lt;/code&gt; member function calls &lt;code&gt;AddPlate&lt;/code&gt; and passes &lt;code&gt;nullptr&lt;/code&gt; as the first argument. The &lt;code&gt;part_plate&lt;/code&gt; parameter is checked two out of the three times where it's used. If a check is missing somewhere, the compiler may assume that the other checks are unnecessary as well and remove them for optimization purposes.&lt;/p&gt;

&lt;p&gt;We can fix the code by adding the missing check. Here's a fun fact: if we look at the &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/commit/14cb2449c6b4b60ea9587e8f94ae32d554b10a8f#diff-b491cdc4033e90ac53f2919d673d1a51e1e673ca4143cf0b9887905e537f22f1L458-R463" rel="noopener noreferrer"&gt;commit history&lt;/a&gt;, we can see that &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/commit/14cb2449c6b4b60ea9587e8f94ae32d554b10a8f#diff-b491cdc4033e90ac53f2919d673d1a51e1e673ca4143cf0b9887905e537f22f1L461" rel="noopener noreferrer"&gt;there was&lt;/a&gt; originally a ternary operator there, but the code was later rewritten.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example N7&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v797/" rel="noopener noreferrer"&gt;V797&lt;/a&gt; The 'find' function is used as if it returned a bool type. The return value of the function should probably be compared with std::string::npos. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/HintNotification.cpp#L175" rel="noopener noreferrer"&gt;HintNotification.cpp 175&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;TagCheckResult&lt;/span&gt; &lt;span class="nf"&gt;tag_check_material&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;GUI&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Tab&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;tab&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wxGetApp&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;get_tab&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Preset&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;TYPE_FILAMENT&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// search PrintConfig filament_type to find if allowed tag&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wxGetApp&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;app_config&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"filament_type"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Preset&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;preset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tab&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;m_presets&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;get_edited_preset&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="k"&gt;auto&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;opt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
        &lt;span class="n"&gt;preset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;opt&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ConfigOptionStrings&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"filament_type"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;opt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;TagCheckAffirmative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;TagCheckNegative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;TagCheckNotCompatible&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;TagCheckNotCompatible&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code contains a comment explaining that a tag needs to be found. Below is the condition where the tag is searched for. However, it doesn't work as intended:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if the tag is found at the beginning, &lt;code&gt;find&lt;/code&gt; returns &lt;code&gt;0&lt;/code&gt;, which is converted to &lt;code&gt;false&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;if the tag is found somewhere in the middle, &lt;code&gt;find&lt;/code&gt; returns a positive number, which is converted to &lt;code&gt;true&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;if the tag is not found, &lt;code&gt;find&lt;/code&gt; returns &lt;code&gt;std::string::npos&lt;/code&gt;, which is also converted to &lt;code&gt;true&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a result, the condition doesn't check whether the tag was found. Instead, it checks whether the tag isn't located at the beginning of the string. The fix may look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wxGetApp&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;app_config&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"filament_type"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;npos&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example N8&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v714/" rel="noopener noreferrer"&gt;V714&lt;/a&gt; Variable 'face' is not passed into foreach loop by a reference, but its value is changed inside of the loop. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/libslic3r/MeshBoolean.cpp#L153" rel="noopener noreferrer"&gt;MeshBoolean.cpp 153&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;_Mesh&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; 
  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;triangle_mesh_to_cgal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;TriangleMesh&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_Mesh&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="c1"&gt;// Number the faces because 'orient_to_bound_a_volume' &lt;/span&gt;
  &lt;span class="c1"&gt;// needs a face &amp;lt;--&amp;gt; index map&lt;/span&gt;
  &lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;face&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;faces&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;          &lt;span class="c1"&gt;// &amp;lt;=&lt;/span&gt;
    &lt;span class="n"&gt;face&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CGAL&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;SM_Face_index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The analyzer reports a suspicious range-based loop: the &lt;code&gt;face&lt;/code&gt; loop variable is declared as a copy of the current element from the &lt;code&gt;out.faces()&lt;/code&gt; range, but the code modifies it on every iteration. Most likely, the code was intended to modify elements inside the &lt;code&gt;out.faces()&lt;/code&gt; range.&lt;/p&gt;

&lt;p&gt;If you need to modify elements within a range, declare the loop variable as an lvalue reference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;face&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;faces&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; 
  &lt;span class="n"&gt;face&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CGAL&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;SM_Face_index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's also make sure that the elements in the &lt;code&gt;out.faces()&lt;/code&gt; range aren't the same as &lt;code&gt;std::reference_wrapper&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Spoiler: no, they aren't
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;I&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Iterator_range&lt;/span&gt;
  &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;pair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;I&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;I&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;public:&lt;/span&gt;
  &lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;second&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="n"&gt;Iterator_range&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="n"&gt;make_range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Iterator_range&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// .... &lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SM_Index&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="nl"&gt;public:&lt;/span&gt;
  &lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="n"&gt;boost&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;uint32_t&lt;/span&gt; &lt;span class="n"&gt;size_type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="nl"&gt;protected:&lt;/span&gt;
  &lt;span class="n"&gt;size_type&lt;/span&gt; &lt;span class="n"&gt;idx_&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SM_Face_index&lt;/span&gt;
  &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;SM_Index&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;SM_Face_index&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* .... */&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="n"&gt;SM_Face_index&lt;/span&gt; &lt;span class="n"&gt;Face_index&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;P&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Surface_mesh&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="nl"&gt;private:&lt;/span&gt;
  &lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;Index_&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Index_iterator&lt;/span&gt;
    &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;boost&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;iterator_facade&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;Index_iterator&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Index_&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                     &lt;span class="n"&gt;Index_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                     &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;random_access_iterator_tag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                     &lt;span class="n"&gt;Index_&lt;/span&gt;
                                   &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="nl"&gt;private:&lt;/span&gt;
    &lt;span class="k"&gt;friend&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;boost&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;iterator_core_access&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// ....&lt;/span&gt;
    &lt;span class="n"&gt;Index_&lt;/span&gt; &lt;span class="n"&gt;dereference&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;hnd_&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;Index_&lt;/span&gt; &lt;span class="n"&gt;hnd_&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Surface_mesh&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;mesh_&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
  &lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="n"&gt;Index_iterator&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Face_index&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Face_iterator&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="n"&gt;Iterator_range&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Face_iterator&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Face_range&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="n"&gt;Face_iterator&lt;/span&gt; &lt;span class="nf"&gt;faces_begin&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Face_iterator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Face_index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;/// End iterator for faces.&lt;/span&gt;
  &lt;span class="n"&gt;Face_iterator&lt;/span&gt; &lt;span class="nf"&gt;faces_end&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Face_iterator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Face_index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_faces&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;Face_range&lt;/span&gt; &lt;span class="nf"&gt;faces&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;make_range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;faces_begin&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;faces_end&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;There's a lot of code here, so let's try to break it down. In the &lt;code&gt;triangle_mesh_to_cgal&lt;/code&gt; function template, the out parameter has the &lt;code&gt;_Mesh&lt;/code&gt; template type. Most often, function template arguments are specializations of the &lt;code&gt;Surface_mesh&lt;/code&gt; class template.&lt;/p&gt;

&lt;p&gt;In the private class section, the template of the &lt;code&gt;Index_iterator&lt;/code&gt; iterator, which inherits from &lt;code&gt;[boost::iterator_facade](https://www.boost.org/doc/libs/latest/libs/iterator/doc/facade-and-adaptor.html)&lt;/code&gt;, is defined. Essentially, this class template simplifies iterator implementation. Let's take a look at its template parameters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;
    &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Derived&lt;/span&gt; &lt;span class="c1"&gt;// The derived iterator type being constructed&lt;/span&gt;
  &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Value&lt;/span&gt;
  &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CategoryOrTraversal&lt;/span&gt;
  &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Reference&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Value&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
  &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Difference&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;ptrdiff_t&lt;/span&gt;
&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;iterator_facade&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fourth template parameter specifies the &lt;code&gt;[reference](https://cppreference.com/cpp/iterator/iterator_traits)&lt;/code&gt; type, which is the value the iterator returns when dereferenced. If it isn't specified explicitly, &lt;code&gt;reference&lt;/code&gt; defaults to &lt;code&gt;Value &amp;amp;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Index_iterator&lt;/code&gt; class template we're interested in passes its own template type as the fourth argument. This means dereferencing the iterator returns a copy of &lt;code&gt;Index_&lt;/code&gt;. The &lt;code&gt;Index_&lt;/code&gt; template parameter is of the &lt;code&gt;Face_index&lt;/code&gt; type. This is an alias of the &lt;code&gt;SM_Face_index&lt;/code&gt; type, which doesn't define any data members and inherits from the &lt;code&gt;SM_Index&lt;/code&gt; class template. The &lt;code&gt;SM_Index&lt;/code&gt; class template defines a single &lt;code&gt;idx&lt;/code&gt; data member of the &lt;code&gt;boost::uint32_t&lt;/code&gt; type, which is a built-in integral type.&lt;/p&gt;



&lt;br&gt;
&lt;p&gt;&lt;/p&gt;

&lt;p&gt;I find it difficult to say what the code should've looked like here, since changing the &lt;code&gt;face&lt;/code&gt; variable type to &lt;code&gt;auto &amp;amp;&lt;/code&gt; doesn't seem like a valid fix. Moreover, the code should stop compiling because an lvalue reference can't bind to a prvalue object.&lt;/p&gt;

&lt;p&gt;When &lt;code&gt;Face_iterator&lt;/code&gt; is dereferenced, it returns a copy of the &lt;code&gt;Face_index&lt;/code&gt; object. To modify anything within the &lt;code&gt;out.faces()&lt;/code&gt; range, the iterator would need to return a reference and somehow be connected to the &lt;code&gt;Surface_mesh&lt;/code&gt; internal data. In that case, the range-based &lt;code&gt;for&lt;/code&gt; loop would work correctly. However, &lt;code&gt;Surface_mesh&lt;/code&gt; and its iterator come from a third-party library, and I doubt we can make any changes there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example N9&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v609/" rel="noopener noreferrer"&gt;V609&lt;/a&gt; Divide by zero. Denominator range [0x0..0x7FFFFFFFFFFFFFFF]. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/libslic3r/Support/TreeSupport3D.cpp#L811" rel="noopener noreferrer"&gt;TreeSupport3D.cpp 811&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="n"&gt;nodiscard&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;Polygons&lt;/span&gt; &lt;span class="nf"&gt;safe_offset_inc&lt;/span&gt;&lt;span class="p"&gt;(....)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;distance&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;do_final_difference&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ret&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;collision_trimmed&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
                               &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;union_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ret&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;safe_step_size&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;last_step_offset_without_check&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;BOOST_LOG_TRIVIAL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;warning&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
      &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"Offset increase got invalid parameter!"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;tree_supports_show_error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s"&gt;"Negative offset distance... How did you manage this ?"&lt;/span&gt;&lt;span class="n"&gt;sv&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;do_final_difference&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ret&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;collision_trimmed&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
                               &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;union_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ret&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;coord_t&lt;/span&gt; &lt;span class="n"&gt;step_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;safe_step_size&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;steps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;last_step_offset_without_check&lt;/span&gt; 
                &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;distance&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;last_step_offset_without_check&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;step_size&lt;/span&gt;
                &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The analyzer reports a division by zero. To understand what's happening, we'll start from the end. The &lt;code&gt;step_size&lt;/code&gt; variable equals &lt;code&gt;safe_step_size&lt;/code&gt;, which means the division by zero occurs if &lt;code&gt;safe_step_size == 0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;At the beginning of the function, there's a &lt;code&gt;safe_step_size &amp;lt; 0&lt;/code&gt; check, which catches only negative values and doesn't check for zero. This means the function doesn't return early when &lt;code&gt;safe_step_size == 0&lt;/code&gt;, which eventually leads to a division by zero.&lt;/p&gt;

&lt;p&gt;This issue appears quite often and is related to using the constants 0, 1, and 2. We noticed this pattern and even wrote an article about it: "&lt;a href="https://pvs-studio.com/en/blog/posts/cpp/0713/" rel="noopener noreferrer"&gt;Zero, one, two, Freddy's coming for you&lt;/a&gt;."&lt;/p&gt;

&lt;p&gt;Other V609 warnings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;V609 Divide by zero. Denominator range [0..2]. GCode.hpp 303&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example N10&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v593/" rel="noopener noreferrer"&gt;V593&lt;/a&gt; Consider reviewing the expression of the 'A = B &amp;lt; C' kind. The expression is calculated as following: 'A = (B &amp;lt; C)'. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/libslic3r/PerimeterGenerator.cpp#L1057" rel="noopener noreferrer"&gt;PerimeterGenerator.cpp 1057&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;LineType&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LinesDistancer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="n"&gt;Floating&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;conditional&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;is_floating_point&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Scalar&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;::&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Scalar&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;::&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;SIGNED_DISTANCE&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Floating&lt;/span&gt; &lt;span class="n"&gt;distance_from_lines&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="cm"&gt;/*.... */&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;//....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;tuple&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ExtrusionPaths&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Polygons&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 
  &lt;span class="n"&gt;generate_extra_perimeters_over_overhangs&lt;/span&gt;&lt;span class="p"&gt;(....)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;size_t&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;overhang_region&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;front&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;polyline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Point&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;overhang_region&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;front&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;polyline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;points&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;to_point&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
      &lt;span class="n"&gt;lower_layer_aabb_tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distance_from_lines&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;min_dist&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;min_dist&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;min_dist_idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The devs wanted to write clean code, but overlooked operator precedence. The &lt;code&gt;&amp;lt;&lt;/code&gt; operator has higher precedence than assignment, so the &lt;code&gt;d&lt;/code&gt; variable receives the result of the comparison—a &lt;code&gt;bool&lt;/code&gt; value instead of &lt;code&gt;double&lt;/code&gt;. As a result, &lt;code&gt;min_dist&lt;/code&gt; gets either &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt; instead of the actual distance. Here's how we can fix this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;lower_layer_aabb_tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distance_from_lines&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;min_dist&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, we can fix it like this if the compiler supports the &lt;code&gt;if&lt;/code&gt; statement with an initializer (C++17):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;lower_layer_aabb_tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distance_from_lines&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;min_dist&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example N11&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v766/" rel="noopener noreferrer"&gt;V766&lt;/a&gt; An item with the same key '"open"' has already been added. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/Widgets/DialogButtons.hpp#L68-L69" rel="noopener noreferrer"&gt;DialogButtons.hpp 69&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DialogButtons&lt;/span&gt;  &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;wxPanel&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;private:&lt;/span&gt;
  &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;wxString&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxStandardID&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;m_standardIDs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Choice&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"ok"&lt;/span&gt;         &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxID_OK&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"yes"&lt;/span&gt;        &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxID_YES&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"apply"&lt;/span&gt;      &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxID_APPLY&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"confirm"&lt;/span&gt;    &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxID_APPLY&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="c1"&gt;// no id for confirm, reusing wxID_APPLY&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"no"&lt;/span&gt;         &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxID_NO&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"cancel"&lt;/span&gt;     &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxID_CANCEL&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="c1"&gt;// Action&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"open"&lt;/span&gt;       &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxID_PRINT&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;  &lt;span class="c1"&gt;// &amp;lt;=&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"open"&lt;/span&gt;       &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxID_OPEN&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;   &lt;span class="c1"&gt;// &amp;lt;=&lt;/span&gt;
  &lt;span class="c1"&gt;//....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two elements with the &lt;code&gt;open&lt;/code&gt; key were added to the initialization of &lt;code&gt;std::map&lt;/code&gt;. A container can't store multiple elements with the same key, so the second element won't be added.&lt;/p&gt;

&lt;p&gt;Looking at the values, we can see that the key for &lt;a href="https://docs.wxwidgets.org/3.2/defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbba4d4fdc32f37cc92c05d7a4ff2bb12ee2" rel="noopener noreferrer"&gt;wxID_PRINT&lt;/a&gt; wasn't updated after copying. As a result, the wrong value will be used. The fix may look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"print"&lt;/span&gt;      &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxID_PRINT&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; 
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"open"&lt;/span&gt;       &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wxID_OPEN&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;/p&gt;
  Other V766 warnings
  &lt;br&gt;
V766 An item with the same key '"use_firmware_retraction"' has already been added. Print.cpp 229&lt;br&gt;
V766 An item with the same key '"filament_notes"' has already been added. Print.cpp 237&lt;br&gt;
V766 An item with the same key '"nozzle_volume"' has already been added. PrintConfig.cpp 8201&lt;br&gt;
V766 An item with the same key '"inner-outer-inner wall/infill"' has already been added. PrintConfig.cpp 272



&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example N12&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v734/" rel="noopener noreferrer"&gt;V734&lt;/a&gt; An excessive expression. Examine the substrings "plus" and "xplus". &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/Utils/QidiPrinterAgent.cpp#L375" rel="noopener noreferrer"&gt;QidiPrinterAgent.cpp 375&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;QidiPrinterAgent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;infer_series_id&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;model_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;dev_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;   &lt;span class="p"&gt;(&lt;/span&gt;   &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"xplus"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;npos&lt;/span&gt; 
          &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"plus"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;npos&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"4"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;npos&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The analyzer detected an unnecessary call in the condition. If &lt;code&gt;key&lt;/code&gt; contains the &lt;code&gt;xplus&lt;/code&gt; substring, it also contains &lt;code&gt;plus&lt;/code&gt;. The second &lt;code&gt;find("plus")&lt;/code&gt; check is redundant because it will always evaluate to true whenever the first one does. Checking &lt;code&gt;plus&lt;/code&gt; is enough:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"plus"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;npos&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"4"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;npos&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code also looks rather inefficient: the string is iterated over three times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example N13&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v583/" rel="noopener noreferrer"&gt;V583&lt;/a&gt; The '?:' operator, regardless of its conditional expression, always returns one and the same value: wxEmptyString. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/Search.cpp#L96" rel="noopener noreferrer"&gt;Search.cpp 96&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;Option&lt;/span&gt; &lt;span class="nf"&gt;create_option&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;opt_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;wxString&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="n"&gt;Preset&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Type&lt;/span&gt; &lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;GroupAndCategory&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;gc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;wxString&lt;/span&gt; &lt;span class="n"&gt;suffix&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;wxString&lt;/span&gt; &lt;span class="n"&gt;suffix_local&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;category&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"Machine limits"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//suffix       = opt_key.back() == '1' ? L("Stealth") : L("Normal");&lt;/span&gt;
    &lt;span class="n"&gt;suffix&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;opt_key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;back&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sc"&gt;'1'&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;wxEmptyString&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;wxEmptyString&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;suffix_local&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;" "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;suffix&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;suffix&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;" "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;suffix&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's a typo in the ternary operator: both branches return &lt;code&gt;wxEmptyString&lt;/code&gt;. The condition doesn't affect the result. The commented-out line above indicates that the code previously had different logic, but it works differently in its current form.&lt;/p&gt;

&lt;p&gt;The exact same code was copied to another snippet as well:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/docs/warnings/v583/" rel="noopener noreferrer"&gt;V583&lt;/a&gt; The '?:' operator, regardless of its conditional expression, always returns one and the same value: wxEmptyString. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/slic3r/GUI/Search.cpp#L348" rel="noopener noreferrer"&gt;Search.cpp 348&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example N14&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v670/" rel="noopener noreferrer"&gt;V670&lt;/a&gt; The uninitialized class member 'm_result' is used to initialize the 'm_options_z_corrector' member. Remember that members are initialized in the order of their declarations inside a class. &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/libslic3r/GCode/GCodeProcessor.cpp#L1671" rel="noopener noreferrer"&gt;GCodeProcessor.cpp 1671&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OptionsZCorrector&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;GCodeProcessorResult&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;m_result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nl"&gt;public:&lt;/span&gt;
  &lt;span class="k"&gt;explicit&lt;/span&gt; &lt;span class="n"&gt;OptionsZCorrector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GCodeProcessorResult&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;m_result&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;GCodeProcessor&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="n"&gt;OptionsZCorrector&lt;/span&gt; &lt;span class="n"&gt;m_options_z_corrector&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// line: 811&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
  &lt;span class="n"&gt;GCodeProcessorResult&lt;/span&gt; &lt;span class="n"&gt;m_result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;           &lt;span class="c1"&gt;// line: 843&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;GCodeProcessor&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;GCodeProcessor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;m_options_z_corrector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m_result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An uninitialized variable is used in the constructor initialization list. Class data members initialize in the order they're declared, and in this code, &lt;code&gt;m_options_z_corrector&lt;/code&gt; initializes &lt;a href="https://github.com/OrcaSlicer/OrcaSlicer/blob/a167702038496b97e8495cc79f0c62660063ac87/src/libslic3r/GCode/GCodeProcessor.hpp#L811-L843" rel="noopener noreferrer"&gt;before&lt;/a&gt; &lt;code&gt;m_result&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Currently, the code works correctly because memory for the object gets allocated before initialization begins. In this case, it's possible to retrieve the address and read it, which is exactly what happens in the &lt;code&gt;OptionsZCorrector&lt;/code&gt; constructor. However, if the constructor starts using the &lt;code&gt;m_result&lt;/code&gt; variable, it will lead to undefined behavior.&lt;/p&gt;

&lt;p&gt;To fix the code, the data member declarations in the class should be reordered so that &lt;code&gt;m_result&lt;/code&gt; appears before &lt;code&gt;m_options_z_corrector&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Looking ahead
&lt;/h2&gt;

&lt;p&gt;If you wish to minimize errors in your projects, incorporate static analysis into your &lt;a href="https://pvs-studio.com/en/blog/posts/1218/" rel="noopener noreferrer"&gt;regular workflow&lt;/a&gt;—and &lt;a href="https://pvs-studio.com/en/pvs-studio/download/?utm_source=website&amp;amp;utm_medium=devto&amp;amp;utm_campaign=article&amp;amp;utm_content=1389" rel="noopener noreferrer"&gt;PVS-Studio&lt;/a&gt; can help you do just that.&lt;/p&gt;

&lt;p&gt;You can &lt;a href="https://pvs-studio.com/en/order/" rel="noopener noreferrer"&gt;request pricing&lt;/a&gt;, a &lt;a href="https://pvs-studio.com/en/pvs-studio/try-free/?utm_source=website&amp;amp;utm_medium=devto&amp;amp;utm_campaign=article&amp;amp;utm_content=1389" rel="noopener noreferrer"&gt;trial version&lt;/a&gt;, or learn &lt;a href="https://pvs-studio.com/en/blog/posts/1286/" rel="noopener noreferrer"&gt;about free licensing terms&lt;/a&gt; in the relevant sections. &lt;/p&gt;

&lt;p&gt;Look ahead to your project's future and catch errors as early as possible :)&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>programming</category>
      <category>software</category>
      <category>tooling</category>
    </item>
    <item>
      <title>JS &amp; TS digest: ES2026 updates, runtime showdown, and PVS-Studio EAP</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Fri, 26 Jun 2026 12:32:06 +0000</pubDate>
      <link>https://dev.to/pvsdev/js-ts-digest-es2026-updates-runtime-showdown-and-pvs-studio-eap-26d0</link>
      <guid>https://dev.to/pvsdev/js-ts-digest-es2026-updates-runtime-showdown-and-pvs-studio-eap-26d0</guid>
      <description>&lt;p&gt;While frontend engineers keep rebuilding their projects around new build tools, JavaScript itself keeps getting faster, safer, and more mature. Here's the most interesting JS and TS news from the past few months.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2cmcy7dfikidq53v8ane.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2cmcy7dfikidq53v8ane.png" alt="1388_jsdigest/image1.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing ES2026: what's new in the standard?
&lt;/h2&gt;

&lt;p&gt;TC39 has officially approved a list of features for &lt;a href="https://socket.dev/blog/tc39-advances-temporal-to-stage-4" rel="noopener noreferrer"&gt;ECMAScript 2026&lt;/a&gt;. The language continues to shed its old "baggage":&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Explicit Resource Management&lt;/strong&gt; (the &lt;code&gt;using&lt;/code&gt; keyword). This feature has been in development for a long time in TypeScript and finally landed in native JavaScript. Now you can automatically allocate resources as soon as a variable goes out of scope.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Iterator Helpers&lt;/strong&gt; (new methods for iterators). You no longer need to convert iterators to arrays using &lt;code&gt;Array.from()&lt;/code&gt; just to call &lt;code&gt;.map()&lt;/code&gt; or &lt;code&gt;.filter()&lt;/code&gt;. Lazy evaluation is now available right out of the box.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can track the progress of these features and their status in the official &lt;a href="https://github.com/tc39/proposals" rel="noopener noreferrer"&gt;TC39 GitHub Proposals&lt;/a&gt; repository. The Explicit Resource Management and Iterator Helpers features are now in the final development stages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Runtime Showdown: Node.js against the World
&lt;/h2&gt;

&lt;p&gt;In 2026, Node.js finally cemented its status as a mature development environment that successfully adopts features from newer competitors (Bun and Deno). The biggest trend this year in runtime environments is running TypeScript files without third-party tools or transpilers like ts-node, thanks to fast built-in parsers.&lt;/p&gt;

&lt;p&gt;Full details are on the &lt;a href="https://nodejs.org/en/blog" rel="noopener noreferrer"&gt;Node.js Official Blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;TypeScript 7.0: Beta announcement and migration to Go&lt;/p&gt;

&lt;p&gt;On April 21, 2026, Microsoft officially released TypeScript 7.0 Beta. This isn't just a minor update but a major revolution under the hood.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The tsgo compiler&lt;/strong&gt;. The development team has fully ported the existing type-checking logic from the old JS/TS engine to the new native compiler written in Go.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;10x faster&lt;/strong&gt;. Go's multithreading brings a tenfold speedup in build and type-checking times for large projects, compared to 6.0.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Architectural parity&lt;/strong&gt;. The language's semantics remained the same: Microsoft carefully moved the framework's code to ensure that existing projects wouldn't break during the transition. The new feature is already being tested extensively at Slack, Google, Figma, and Vercel.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Early Access: PVS-Studio's new JavaScript &amp;amp; TypeScript analyzers
&lt;/h2&gt;

&lt;p&gt;We've spent years specializing in C, C++, C#, and Java—but web development has grown too important to ignore. We're now building new analyzers for JavaScript and TypeScript, and we'd like you to try them!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Feisey9dqq9v8ma4le747.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Feisey9dqq9v8ma4le747.png" alt="1388_jsdigest/image2.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PVS-Studio is currently running the Early Access Program. As part of the EAP, our priority is to check whether the new analyzers are stable, perform well, and produce high-quality analysis on real projects. We invite you to participate in the testing: &lt;a href="https://pvs-studio.com/en/pvs-studio-eap/" rel="noopener noreferrer"&gt;sign up here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to read?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/AllThingsSmitty/typescript-tips-everyone-should-know" rel="noopener noreferrer"&gt;TypeScript Tips Everyone Should Know&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article provides a roundup of practical TypeScript techniques for improving safety, readability, and developer experience. For example, the author advises using safe input data validation, fewer unnecessary type signatures, &lt;code&gt;satisfies&lt;/code&gt; instead of rough type casting, etc. More useful patterns are in the full article.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/js/1381/" rel="noopener noreferrer"&gt;Error that we had to ignore&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Developing a static analyzer, as with any software project, involves trade-offs. Sometimes this means dropping perfectly valid analyzer warnings to make the tool better overall. The article illustrates this trade-off through a diagnostic rule designed to detect typos caused by identical operands in binary expressions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://odysse.io/en/javascript-in-2026-a-comprehensive-guide-to-the-ecosystem-revolution/" rel="noopener noreferrer"&gt;JavaScript in 2026: A Comprehensive Guide to the Ecosystem Revolution&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you missed the Runtime Wars, you can read this comprehensive overview. You'll explore how fierce competition between Node.js, Bun, and Deno has forced all players to implement native TypeScript support and built-in security tools. This is a great long-read article for understanding where the entire industry is headed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.logrocket.com/typescript-at-scale-2026/" rel="noopener noreferrer"&gt;TypeScript at scale in 2026: What senior engineers should know&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article focuses on how to effectively use TypeScript in large codebases, monorepos, and large teams. The author points out that by 2026, the question of whether to use TypeScript is no longer relevant. The language has become the standard, shifting the focus toward efficiently managing code at the system level.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to listen?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://typescript.fm/" rel="noopener noreferrer"&gt;Podcast: TypeScript.fm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you've been searching for a focused, lively show about TypeScript, this is it. Hosts Kamran Ayub and Erik Onarheim cover the latest language updates. In a recent episode, they discussed the updates to TypeScript 7.0 Beta and debated why the new tsgo compiler sometimes uses too much memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://syntax.fm/" rel="noopener noreferrer"&gt;Podcast: Syntax.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Meet one of the well-known podcasts on frontend and full-stack development, hosted by Wes Bos, Scott Tolinski, and CJ Reynolds. No fluff, just a strong focus on practice and experience. Every week, they release episodes in a variety of formats: from in-depth analyses of complex bugs in JavaScript and TypeScript to relaxed Supper Club interviews with creators of top-tier libraries, frameworks, and modern automation tools like Biome, ESLint, and Vite.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap-up
&lt;/h2&gt;

&lt;p&gt;Thank you for reading our digest! Share with us any other fresh news or events you find noteworthy. You can submit them using our &lt;a href="https://pvs-studio.com/en/about-feedback/?is_question_form_open=true" rel="noopener noreferrer"&gt;feedback form&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To stay up to date on the latest news, follow us on &lt;a href="https://x.com/pvs_studio" rel="noopener noreferrer"&gt;X&lt;/a&gt; and &lt;a href="https://www.linkedin.com/company/pvs-studio" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;. We post articles by our company's experts, video reviews featuring the latest analyzer updates, event announcements, memes, and much more. Most importantly, you're always welcome to leave comments—we'll be happy to respond!&lt;/p&gt;

&lt;p&gt;Don't forget, PVS-Studio stands guard over your codebase.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/jsdigest" rel="noopener noreferrer"&gt;Get the 30-day trial promo code here!&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>news</category>
    </item>
    <item>
      <title>We're building custom programming language—would you join us?</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Tue, 23 Jun 2026 14:24:50 +0000</pubDate>
      <link>https://dev.to/pvsdev/were-building-custom-programming-language-would-you-join-us-3afa</link>
      <guid>https://dev.to/pvsdev/were-building-custom-programming-language-would-you-join-us-3afa</guid>
      <description>&lt;p&gt;What is expertise, and what lies at its core? Expertise varies in depth, field, and purpose. But some things never change: it can't exist without theory and experience; it can't emerge in an environment free from challenges and mistakes. Every person develops their own unique expertise. Today, we'll share our experience, which may inspire you to enhance your expertise. Also, we invite you to challenge your brain and guess some unexpected inventions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwy9xzwtiryg023i8dchm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwy9xzwtiryg023i8dchm.png" alt="1387_letsmakelanguage/image1.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What gives rise to expertise in programming? In the past, it was curiosity—the urge to simplify and overcome challenges. Today, it shaped by projects that deliver business value. But even now, we can arm ourselves with those qualities and reach the outcomes we aim for. After all, code lets us stay flexible and venture down untrodden paths. Quite often, they can lead to the beginning of something much greater—and history has plenty of proof.&lt;/p&gt;

&lt;p&gt;Below, you'll find stories of such unexpected success. Can you guess what invention each one describes? Share your guesses in the comments or read the article to the end, where we'll reveal all the secrets.&lt;/p&gt;

&lt;h2&gt;
  
  
  Story #1
&lt;/h2&gt;

&lt;p&gt;A Danish-Canadian developer wanted to create a convenient tool for tracking visits to his online CV. The solution proved so useful and effective and quickly went beyond personal use. It still remains popular among web developers. What is the solution?&lt;/p&gt;

&lt;h2&gt;
  
  
  Story #2
&lt;/h2&gt;

&lt;p&gt;Two developers set out to solve the problem of migrating software from 32-bit to 64-bit systems. They created a tool to help detect errors the transition caused. Later, they realized it could also find other issues and transformed it into a full-featured tool that could handle a wider range of tasks. What the solution does?&lt;/p&gt;

&lt;h2&gt;
  
  
  Story #3
&lt;/h2&gt;

&lt;p&gt;An engineer came up with this solution to fix an issue in his online store where items would simply disappear from the cart when users navigated to another store section. Today, this discovery powers the entire world of online advertising and user tracking.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does expertise mean for PVS-Studio?
&lt;/h2&gt;

&lt;p&gt;We hope you guessed what the solutions were. Now, let's go back to the main topic: expertise. Why does our company value it? How does it reveal itself in our work? Now we'll show how our new practice helps transform our expertise into benefits for the developer community.&lt;/p&gt;

&lt;p&gt;We work closely with programming languages because our mission is to help developers write clean code. Our devs should understand languages down to their core to create algorithms that detect common and critical errors, as well as potential vulnerabilities in code. This expertise enables us to teach computers how to automatically identify issues.&lt;/p&gt;

&lt;p&gt;The number of diagnostic rules that catch issues in your projects continues to grow every year.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe0jgiuvc46van9abx6n1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe0jgiuvc46van9abx6n1.png" alt="1387_letsmakelanguage/image2.png" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What stands behind these rules, though? What does the analyzer rely on when searching for errors? It's the core! It powers our &lt;a href="https://pvs-studio.com/en/blog/terms/7004/" rel="noopener noreferrer"&gt;data flow analysis&lt;/a&gt;, &lt;a href="https://pvs-studio.com/en/blog/terms/6776/" rel="noopener noreferrer"&gt;signature analysis&lt;/a&gt;, &lt;a href="https://pvs-studio.com/en/blog/posts/1166/" rel="noopener noreferrer"&gt;method annotations&lt;/a&gt;, and all our other analysis technologies. Yuri, our core architect, handles this and other numerous areas. He's a great engineer, a proud cat dad, and simply a cool guy. While going through yet another epic battle with core-level challenges—it's hard to imagine what he deals with every day while diving so deep into the tool's innards—Yuri was pulled away from his usual work by an offer from his colleagues...&lt;/p&gt;

&lt;p&gt;PVS-Studio has a department called Te&amp;amp;De (Teaching &amp;amp; Development). Two wonderful employees, Inna and Yulia, handle internal trainings for our employees. They also organize live talks for managers and developers. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can find information about the upcoming and past talks &lt;a href="https://pvs-studio.com/en/webinar/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;They suggested Yuri share his knowledge in the internal training course for new employees. As the course took shape, we realized that its content would benefit not only new colleagues, but also the broader dev community. This led to the decision to make the materials publicly available for free.&lt;/p&gt;

&lt;h2&gt;
  
  
  A few words about the series of live talks
&lt;/h2&gt;

&lt;p&gt;Since Yuri isn't a fan of text storytelling, we took it upon ourselves to introduce his original series of live talks about creating a toy programming language where he explains what lies behind almost every programming language. Understanding how it works is one thing—teaching a machine to understand it is a much harder challenge.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgck6s1zpg90yn7w6sz8u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgck6s1zpg90yn7w6sz8u.png" alt="1387_letsmakelanguage/image3.png" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It all starts with &lt;a href="https://pvs-studio.com/en/blog/video/11644/" rel="noopener noreferrer"&gt;grammar&lt;/a&gt;, which describes the language structure.&lt;/p&gt;

&lt;p&gt;When it comes to parsing code, the &lt;a href="https://pvs-studio.com/en/blog/video/11665/" rel="noopener noreferrer"&gt;lexer&lt;/a&gt; takes the stage. It extracts individual words from the text and classifies them.&lt;/p&gt;

&lt;p&gt;The next step is to put words into sentences. This is where the &lt;a href="https://pvs-studio.com/en/blog/video/11709/" rel="noopener noreferrer"&gt;parser&lt;/a&gt; comes into play. It takes the words and turns them into language constructs. Then, we organize these constructs into a syntax tree, a hierarchical structure that represents relationships between individual language parts. We traverse the tree and execute or evaluate what it describes. &lt;/p&gt;

&lt;p&gt;A language also consists of different entities that we can name—and it must recognize and understand these names. This is where semantic analysis comes in. Languages also have data types that interact with each other, and determining how they work together is part of semantics.&lt;/p&gt;

&lt;p&gt;The final piece is the evaluator that traverses the syntax tree and calculates the values of variables and expressions.&lt;/p&gt;

&lt;p&gt;This is roughly what a programming language looks like in a simplified and idealized form. In the live coding sessions, Yuri walks through the entire process while viewers can ask questions and discuss the details.&lt;/p&gt;

&lt;p&gt;Our main goal isn't to teach but to satisfy the curiosity that drives many programmers to dive deeper into the topic. We also want to transform the experience gained from building a static analysis tool into exciting content and share this expertise with others. The steps Yuri goes through when creating his own language form the foundation, but it isn't as simple as it may seem. This series of sessions, designed to help developers build their own language, is one of the easiest ways to understand how programming languages actually work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb8qh4197261o3q11kmpz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb8qh4197261o3q11kmpz.png" alt="1387_letsmakelanguage/image4.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By the way, if you'd like to join Yuri on this journey, there's still time! The next session dedicated to building an Abstract Syntax Tree is scheduled for June 26, 1:00 PM UTC+1. Sign up &lt;a href="https://pvs-studio.com/en/webinar/" rel="noopener noreferrer"&gt;here&lt;/a&gt; and don't forget to check your inbox to confirm the registration!&lt;/p&gt;

&lt;h2&gt;
  
  
  Revealing secrets
&lt;/h2&gt;

&lt;p&gt;While doing our work, we often run into challenges. If we stop, we might miss something important and truly remarkable. But when overcoming a problem, we feel proud of ourselves and gain experience and new skills. By encouraging curiosity, we explore new horizons, sometimes simplify complex things, and open doors we never even knew existed at the beginning of our journey. Now, it's time to lay our cards on the table and tell you what solutions we had in mind.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Story #1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwz8e4moo0kosk8uc4kfk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwz8e4moo0kosk8uc4kfk.png" alt="1387_letsmakelanguage/image5.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Danish-Canadian developer's name is Rasmus Lerdorf, and his invention is Personal Home Page (a set of tools for a personal homepage). It became popular and eventually evolved into PHP, a widely used programming language for websites. Lerdorf combined his scripts with a form-handling library, introducing the basic syntax, and the option to process data from HTML forms. The release of PHP 2.0 turned it into a full-fledged tool for building dynamic websites, revolutionizing web development.&lt;/p&gt;

&lt;p&gt;P.S. One of our designers created this image for another article. It's amazing how large our collection of illustrations has grown over the years, especially considering the exceptional talent of each artist. Recently, our colleague wrote an article on how our mascot, Cody the Unicorn, has changed throughout the entire company's history. Check out &lt;a href="https://pvs-studio.com/en/blog/posts/1372/" rel="noopener noreferrer"&gt;this article&lt;/a&gt; and enjoy the delightful collection of unicorn illustrations and some of the most unconventional designs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Story #2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Of course, it's PVS-Studio. We decided to praise ourselves a little :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbkbhnn75ymryqjv5zlj8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbkbhnn75ymryqjv5zlj8.png" alt="1387_letsmakelanguage/image6.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It was 2006, the dawn of 64-bit systems. Back then, many devs were thinking about moving away from 32-bit systems, but the transition brought its own share of 64-bit bugs. As a result, two developers created a mechanism to catch such errors and later turned it into a tool that tackled a much wider range of issues. Today, PVS-Studio is a full-fledged company. Back then, it started with two recent grads who had a problem, and their solution grew into something much bigger. By the way, the company recently turned 18—they grow up so fast!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Story #3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff2xp3w7vbbokfe2yylb3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff2xp3w7vbbokfe2yylb3.png" alt="1387_letsmakelanguage/image7.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In 1994, Netscape Communications engineer Lou Montulli encountered an issue: the original HTTP protocol was stateless, meaning a server couldn't track when the same user moved from page to page or made purchases. He suggested storing a small piece of text data on the user's side. These became known as &lt;em&gt;cookies&lt;/em&gt;. This invention forever changed the web industry by making it possible to create user-friendly shopping carts for online stores and enabling users to stay logged in to websites.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some parting words
&lt;/h2&gt;

&lt;p&gt;The PVS-Studio team wishes you success in enhancing your expertise. It's a valuable skill that'll help you grow and reach new heights. We also invite you to join our live talks, where you can gain new insights into programming languages and find inspiration for your projects, whether personal or professional. Your curiosity may also lead to something bigger. All you need is &lt;a href="https://pvs-studio.com/en/webinar/30/" rel="noopener noreferrer"&gt;right here&lt;/a&gt;...&lt;/p&gt;

</description>
      <category>programming</category>
      <category>cpp</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>"They generate more bugs, more security holes": C++ creator takes aim at vibe coding</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Mon, 22 Jun 2026 13:46:59 +0000</pubDate>
      <link>https://dev.to/pvsdev/they-generate-more-bugs-more-security-holes-c-creator-takes-aim-at-vibe-coding-90c</link>
      <guid>https://dev.to/pvsdev/they-generate-more-bugs-more-security-holes-c-creator-takes-aim-at-vibe-coding-90c</guid>
      <description>&lt;p&gt;Bjarne Stroustrup, the creator of the C++ programming language, says modern AI tools still aren't reliable for writing high-quality, complex system code or designing programming languages. Bjarne raised the point on the &lt;a href="https://youtu.be/U46fJ2bJ-co" rel="noopener noreferrer"&gt;Ryan Peterman podcast&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I think that in the field I'm mostly interested in code will still be written by humans, and they will use abstraction. The examples I've seen of attempts for AI to generate code in this domain has not been successful. They generate more bugs, more security holes."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Stroustrup points to validation as the real problem: AI-driven changes are harder to track because a small prompt change can spread across many parts of a project.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"All of the code that was generated knows more code generated than if it was written by humans. When a human makes a change, it will make a change that's localized. You can look for the effects of that localized change. If an AI writes it, you don't actually know where it's changed. You have to try and figure that out."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;However, the "father of C++" doesn't dismiss AI entirely. He believes that it can be useful for technical writing, provided human reviews the output.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"It's not, at least now, good at safety-critical, performance-critical code. Now, let's say that 70 or 80% of the world's code doesn't fit that pattern. But it's that 10 or 20% of the code that I'm interested in. And there, it's not there."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The podcast also touched on LLMs. Stroustrup has noted that they're trained on existing code, which means they may inherit old approaches and old habits along with it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I find that LLM-based code is imitating old code and getting old performance and old bugs again. Maybe you can improve that. I hear rumors of Bjarne apps being written that fit my writings, but even that is problematic because I'm not saying exactly the same as I did 20 years ago."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The PVS-Studio team, which builds a static analysis tool with a strong focus on C++, also shared their perspective on the widespread adoption of AI-driven coding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phillip Khandeliants, Head of Static Analyzer Development at PVS-Studio&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Bjarne Stroustrup's criticism lands when a developer just copies and pastes the AI output into a project. Depending on the prompt, the model may generate code that's suboptimal, buggy and/or even insecure. We have seen evidence of this when reviewing vibe-coded projects like &lt;a href="https://pvs-studio.com/en/blog/posts/cpp/1354/?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=media&amp;amp;utm_content=ai" rel="noopener noreferrer"&gt;vib-OS&lt;/a&gt; or &lt;a href="https://pvs-studio.com/en/blog/posts/cpp/1366/?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=media&amp;amp;utm_content=ai" rel="noopener noreferrer"&gt;markus&lt;/a&gt;. To be fair, the authors of those projects did not aim to ship a production-level solution, but rather to run a case study.&lt;br&gt;
We shouldn't forget that AI-generated and human-written code are no longer different in one matter: they both need to be thoroughly checked. It should go through an extensive code review, static and dynamic analysis, and formal verification processes. Used that way, AI agents can significantly streamline developers' workflow by handling boilerplate, routine tests, and early hypothesis generation, ultimately boosting productivity and development speed."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Oleg Lisiy, C++ Team Lead at PVS-Studio&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Absolutely, AI is just part of how people work now, and that's not going away. The real question is how we should leverage it. Letting an AI agent generate code from an issue description and then push it straight to production has no place in enterprise-level software development. It's hard to imagine anyone actually doing this way.&lt;br&gt;
On the other hand, if criticize AI, we should criticize IDE's autocomplete too, shouldn't we? Just imagine a developer mashing random keys, hitting Tab for autocomplete, and committing the result right away. Sounds crazy, doesn't it? The hype around AI feels just as crazy to me."&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>news</category>
      <category>ai</category>
      <category>cpp</category>
    </item>
    <item>
      <title>PVS-Studio 7.43: Unreal Engine support in Team license, extended MISRA C++ 2023, Zephyr SDK support, and more</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Fri, 19 Jun 2026 12:17:35 +0000</pubDate>
      <link>https://dev.to/pvsdev/pvs-studio-743-unreal-engine-support-in-team-license-extended-misra-c-2023-zephyr-sdk-h7f</link>
      <guid>https://dev.to/pvsdev/pvs-studio-743-unreal-engine-support-in-team-license-extended-misra-c-2023-zephyr-sdk-h7f</guid>
      <description>&lt;p&gt;PVS-Studio 7.43 has been released. This version features expanded support for MISRA C++ 2023, Unreal Engine integration in the Team license, Zephyr SDK support and much more.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa8oz6w9kcxn2up59dog9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa8oz6w9kcxn2up59dog9.png" alt="1386_release_7_43/image1.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Unreal Engine support in the Team license
&lt;/h2&gt;

&lt;p&gt;Good news for Unreal Engine developers: analysis of Unreal Engine projects is no longer limited to the &lt;a href="https://pvs-studio.com/en/order/license/" rel="noopener noreferrer"&gt;Enterprise license&lt;/a&gt;. Starting with PVS-Studio 7.43, this functionality is also available in the Team license.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/docs/manual/0043/" rel="noopener noreferrer"&gt;Learn more about the analysis of Unreal Engine projects&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  MISRA C++ 2023
&lt;/h2&gt;

&lt;p&gt;We continue to expand our support for MISRA C++ 2023.&lt;/p&gt;

&lt;p&gt;In this update, we've adapted 12 existing diagnostic rules from the MISRA group to comply with the MISRA C++ 2023 standard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/pvs-studio/sast/misra/" rel="noopener noreferrer"&gt;Lean more about the support of the MISRA standard&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Zephyr SDK support
&lt;/h2&gt;

&lt;p&gt;PVS-Studio 7.43 can now analyze projects that use compilers from the Zephyr SDK. You can inspect such projects via &lt;code&gt;compile_commands.json&lt;/code&gt; or build monitoring.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/docs/manual/6615/" rel="noopener noreferrer"&gt;Learn more&lt;/a&gt; about the integration&lt;/p&gt;

&lt;h2&gt;
  
  
  Analyzer improvements
&lt;/h2&gt;

&lt;p&gt;We've enhanced the interprocedural loop analysis in the C and C++ analyzer. Now the analyzer can evaluate canonical loops and factor in possible value ranges of variables.&lt;/p&gt;

&lt;p&gt;The C# analyzer now supports .NET SDK version 10.0.300 on Linux and macOS. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/docs/manual/0035/" rel="noopener noreferrer"&gt;Learn more about the analyzer usage on these platforms&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Reminder&lt;/strong&gt;: Our Early Access Program for JavaScript and Go analyzers and the Atlas code quality management platform is still open. You can now also evaluate PVS-Studio for TypeScript.&lt;/p&gt;

&lt;p&gt;If you'd like to participate, simply, &lt;a href="https://pvs-studio.com/en/pvs-studio-eap/#form-eap" rel="noopener noreferrer"&gt;please fill out the form on our website&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  New diagnostic rules
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Java
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://pvs-studio.com/en/docs/warnings/v6135/" rel="noopener noreferrer"&gt;V6135&lt;/a&gt;. The return value of the 'finally' block overrides return values of 'try' and 'catch' blocks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Articles
&lt;/h2&gt;

&lt;p&gt;Here is our traditional roundup of blog articles! Over the past two months, we've posted articles exploring vibe-coding, covering alignment in C++, error handling in Go, and the new features of Java 26, celebrating the evolution of our mascot Cody, and much more. Below is the full list.&lt;/p&gt;

&lt;h3&gt;
  
  
  C and C++
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/cpp/1366/" rel="noopener noreferrer"&gt;Let's check vibe code that acts like optimized C++ but is actually a mess&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/cpp/1369/" rel="noopener noreferrer"&gt;Silent foe or quiet ally: Brief guide to alignment in C++. Part 3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/cpp/1374/" rel="noopener noreferrer"&gt;PVS-Studio in CMake: It's official now!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/cpp/1376/" rel="noopener noreferrer"&gt;C++ digest: News, helpful resources, &amp;amp; your own programming language as bonus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/cpp/1379/" rel="noopener noreferrer"&gt;Real-world C++ projects built with GenAI: do they exist?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  C
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/csharp/1367/" rel="noopener noreferrer"&gt;AI integrations: rely or verify? Checking Semantic Kernel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/csharp/1380/" rel="noopener noreferrer"&gt;Bugs and suspicious code fragments in .NET 10&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Java
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/java/1370/" rel="noopener noreferrer"&gt;What's new in Java 26&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  JavaScript
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/js/1381/" rel="noopener noreferrer"&gt;Error that we had to ignore&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Go
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/go/1377/" rel="noopener noreferrer"&gt;Double AI agents: What's hiding in your Golang code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/go/1371/" rel="noopener noreferrer"&gt;Error handling in Go: Common pitfalls&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Security
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/1373/" rel="noopener noreferrer"&gt;Static code analysis and software time to market&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  GameDev
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/1375/" rel="noopener noreferrer"&gt;Game++. Part 1.2: C++, game engines, and architectures&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Other
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/1372/" rel="noopener noreferrer"&gt;Evolution of Cody: PVS-Studio mascot through the years&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Webinars
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Let's make a programming language. Grammars
&lt;/h3&gt;

&lt;p&gt;In our first session, we explored the core building blocks: the lexer, parser, semantic analyzer, and evaluator—how they work and how they fit together. Now it's time to dive into grammars. What is a language, really? How can you describe it in a way that a program understands what a sequence of symbols means and what result it should produce? We'll break it down in a clear and practical way—and, of course, get hands-on with grammars.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/-yuU92URgz8"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's make a programming language. Lexer
&lt;/h3&gt;

&lt;p&gt;The lexer is the part of the parsing pipeline that operates on terminal symbols. It takes a raw input stream and turns it into a sequence of tokens—classifying lexemes into meaningful units. This process, as you know, is called tokenization. We won't stop at theory. During the webinar, we'll walk through how a lexer is actually implemented in code. This session is aimed at developers who want to go beyond using languages and start understanding how they work under the hood.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/yFz1LTtEwz8"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Want to see more webinars, we invite you to check out upcoming events on the &lt;a href="https://pvs-studio.com/en/webinar/" rel="noopener noreferrer"&gt;webinar page&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;If you'd like to receive news about PVS-Studio releases, &lt;a href="https://pvs-studio.com/en/subscribe/" rel="noopener noreferrer"&gt;subscribe to our newsletter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Do you want to check your project with PVS-Studio? &lt;a href="https://pvs-studio.com/en/pvs-studio/try-free/?utm_source=website&amp;amp;utm_medium=devto&amp;amp;utm_campaign=article&amp;amp;utm_content=1386" rel="noopener noreferrer"&gt;Start with a trial license&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>cpp</category>
      <category>go</category>
      <category>java</category>
    </item>
    <item>
      <title>Let's make a programming language. Parser — Key points</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Thu, 18 Jun 2026 13:27:09 +0000</pubDate>
      <link>https://dev.to/pvsdev/lets-make-a-programming-language-parser-key-points-2h2n</link>
      <guid>https://dev.to/pvsdev/lets-make-a-programming-language-parser-key-points-2h2n</guid>
      <description>&lt;p&gt;This is the fourth part in our series of talks on creating a programming language. In this session on building our toy programming language, we focus on the parser, specifically on parsing expressions using recursive descent. &lt;/p&gt;

&lt;h2&gt;
  
  
  About the speaker
&lt;/h2&gt;

&lt;p&gt;Yuri Minaev is an experienced C++ developer, architect at PVS-Studio, and a recognized voice in the C++ community who has spoken at CppCast, C++ on Sea, and CppCon. Over the course of ten sessions, he'll guide you through each stage of building your own programming language.&lt;/p&gt;

&lt;h2&gt;
  
  
  Meet the parser
&lt;/h2&gt;

&lt;p&gt;The parser verifies whether input conforms to the grammar and, if successful, builds an abstract syntax tree (AST). Yuri walks through the grammar for additive, multiplicative, unary, parenthesized, and literal expressions, explaining how precedence and left associativity are baked into the grammar structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Parser implementation
&lt;/h2&gt;

&lt;p&gt;It begins with a straightforward but repetitive version, where separate functions handle additive and multiplicative expressions. This leads to code duplication, especially as more binary operators are added. To solve this, the presenter introduces a generic binary expression function that uses a precedence enum and recursive calls with an increased index. This approach eliminates duplication and handles all binary operators uniformly. &lt;/p&gt;

&lt;p&gt;Yuri demonstrates how the parser descends through the grammar, consuming tokens and building nested structures, with left associativity ensured by loops that repeatedly consume operators of the same precedence. &lt;/p&gt;

&lt;p&gt;The session concludes with a preview of future topics: building an AST, implementing a builder and printer, and using the visitor pattern.&lt;/p&gt;

&lt;h2&gt;
  
  
  Want more?
&lt;/h2&gt;

&lt;p&gt;If you want to watch other talks or see the whole episode, &lt;a href="https://pvs-studio.com/en/blog/video/11709/?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=webinar&amp;amp;utm_content=web5" rel="noopener noreferrer"&gt;follow this link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can also sign up for our upcoming webinars, for example: &lt;a href="https://pvs-studio.com/en/webinar/30/?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=webinar&amp;amp;utm_content=web5" rel="noopener noreferrer"&gt;Let's make a programming language. AST&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you'd like to learn more about PVS-Studio analyzer, check out our &lt;a href="https://pvs-studio.com/en/?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=webinar&amp;amp;utm_content=web5" rel="noopener noreferrer"&gt;website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;See ya!&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>programming</category>
      <category>webinar</category>
    </item>
    <item>
      <title>Game++. Part 1.3: Game engine architectures</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Tue, 16 Jun 2026 14:27:46 +0000</pubDate>
      <link>https://dev.to/pvsdev/game-part-13-game-engine-architectures-227p</link>
      <guid>https://dev.to/pvsdev/game-part-13-game-engine-architectures-227p</guid>
      <description>&lt;p&gt;This book offers insights into C++, including algorithms and practices in game development, explores strengths and weaknesses of the language, its established workflows, and hands-on solutions. C++ continues to dominate the game development industry today thanks to its combination of high performance, flexibility, and extensive low-level control capabilities. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmptsdvexzr1e6gzhybh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmptsdvexzr1e6gzhybh.png" alt="1384_chapter_1_pt_3/image1.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before jumping into game engine architectures, it helps to define what we mean by software architecture and how it relates to games. &lt;/p&gt;

&lt;p&gt;First, architectures are a real thing in game dev, whatever anyone says. Second, there turns out to be more than one. Keeping that in mind makes the rest of this chapter much easier to follow and gives you something to say the next time someone goes off about why a particular engine is either pure genius or complete garbage. &lt;/p&gt;

&lt;p&gt;Most projects follow a similar pattern: code gets written, tools get built, a game gets shipped. The skeleton grows flesh, and only then do all the ignored problems come knocking because getting something out the door was always the priority. But sweeping problems under the backlog rug doesn't make them disappear. &lt;/p&gt;

&lt;p&gt;Every program has an architecture, even if everything lives inside a single &lt;code&gt;main()&lt;/code&gt; and somehow holds together on optimism and luck. The more interesting question is: what actually makes a game engine good? &lt;/p&gt;

&lt;p&gt;Nobody builds an engine for fun. Engines grow from necessity—as development progresses, individual pieces get formalized and stabilized so they can be reused. An editor appears, then an asset pipeline, a dedicated I/O module, a renderer that earns its own codebase, and so on. Eventually a team of engineers gathers around all those systems to keep them running. Most teams only realize this after shipping—by then it's clear that you simply can't keep working the old way. &lt;/p&gt;

&lt;p&gt;Another approach is for the game itself to be the editor, the engine, and the build system all in one—something that can compile itself into finished levels and logic. All game engines and editors grew out of games. Some of those games (and later engine-editors) became successful, and their developers rode that wave to buy more time and resources to keep building. Over time, somebody on the team (grown from within, rarely hired) takes on the job of keeping the growing machinery together, ensuring integrity within the whole system. Sometimes that person carries the title of Architect. More often, they are an engineering veteran who's spent years working alongside programmers, designers, QA, and production. &lt;/p&gt;

&lt;p&gt;For the last ten-plus years I've spent every working day staring at the code of different games and engines, mostly large ones that have been around long enough to grow beards. Like any programmer who's spent a long stretch in one domain, I'd like to think I've developed an eye for good design or, at least, a nose for bad design. Every developer has lived through that moment when the code they were looking at was so bad that the only honest move was to comment it out and rewrite everything around it. Of course, "best technical decision" and "approved by management" are rarely the same thing. Terrible legacy systems often survive for a reason: they are ugly, but battle-tested. Everybody already knows where the landmines are. New code may look cleaner, but you still have to discover its hidden threats. &lt;/p&gt;

&lt;p&gt;Few of us have been lucky enough to work with perfectly designed code. That very code, project, or engine that feels like a luxurious American sedan from the '70s—one that has everything you could want, you just need to know where the controls are—and it's ready to hit 100 fps with just a light tap of the gas pedal. Anyway, working with different codebases, I started noticing that game engines often resemble the teams that build them. &lt;/p&gt;

&lt;p&gt;Once a team grows beyond five or six developers, some kind of organization becomes unavoidable—responsibilities naturally split along the lines of skill and experience. Everybody does what they know best: the internal database, the renderer, physics, the editor, tests, and so on. From a business standpoint that division looks perfectly logical—the right people in the right seats, less overlap, better efficiency. &lt;/p&gt;

&lt;p&gt;Split the team and you split the knowledge, and suddenly different parts of the system struggle to interact effectively. Development then bogs down as specialists dig deeper in their own isolated subsystems and stop talking about the things that actually affect everyone. That artificial divide ultimately hampers knowledge sharing and leaves the engine's components poorly integrated with each other. &lt;/p&gt;

&lt;p&gt;This pattern—the link between an engine's structure and the internal organization of the team behind it—was noted back in the 1960s by Melvin Conway. Conway's Law states that the structures of the organizations involved in designing a system will ultimately be reflected in the architecture of that system. Put simply, it's hard for a team to build something that doesn't end up looking like the way they communicate. &lt;/p&gt;

&lt;p&gt;This isn't specific to engines, it goes for any team-built software. A company split into frontend, backend, and database teams rarely ships a system where those boundaries don't show—the architecture quietly inherits the org chart, whether anyone intended that or not. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;. According to Johnny Leroy, the way to fix a broken architecture is to fix how the team communicates first. The architecture and the team that builds it have to grow in the same direction. Instead of building a system that inherits organizational weak spots, you reshape the organization so it naturally grows something more integrated and flexible.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If the architecture demands tight integration between different parts—say, between gameplay and the renderer—don't keep these teams working in separate corners. Get them talking directly: cross-functional groups, pair programming, or cross-review practices. The knowledge starts flowing and the architecture shifts with it. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A &lt;strong&gt;small warning&lt;/strong&gt; before we continue. In the text below, the architectural labels may not be industry-standard and may be debatable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Unity (Unitary Architecture)
&lt;/h2&gt;

&lt;p&gt;The first time I looked seriously at Unity's internals—not the editor, but the engine architecture underneath—I was mildly horrified. This was around 2014, so perhaps some things have changed, but I'd not bet heavily on it. By then, Unity had already conquered mobile development. I expected a polished architecture and a carefully engineered roadmap. Instead I faced a patchwork quilt of components with three build systems haphazardly thrown together and sealed with a mono-VM. Just like "if it builds, don't touch it", even if it means workarounds everywhere and comments like "Don't remove this space", "Don't compile on Independence Day", or "Build with this constant first; if it doesn't compile, set it to 0." At one point, building the editor involved a separate wiki page listing 117 steps: compile this first, rebuild that second, set these flags, pray if it fails. And the editor had its own separate build system on top of that. But the origin story of Unity explains a lot. &lt;/p&gt;

&lt;p&gt;It all started with GooBall, a game dreamed up in 2001 by students David Helgason, Joachim Ante, and Nicholas Francis. Their studio, Over the Edge Entertainment, ran into the classic indie problems of the early 2000s: expensive engine licenses, complex code, and a lack of resources. The guys shipped the game, but four years of struggle ended in commercial failure. What came out instead—built on that same game source code, those same approaches, and that same team—was Unity. &lt;/p&gt;

&lt;p&gt;In 2005, Unity 1.0 was quietly shown at an Apple conference. An engine built for macOS X seemed to have little chance in a world where almost everyone played on Windows. But that turned out to be its advantage: the Mac was popular with designers, and shortly afterward it became a common platform for early iPhone development. &lt;/p&gt;

&lt;p&gt;Unity stood out right away. Rather than wrestling with complex code, Unity's component-based approach lets you assemble objects like LEGO bricks—snap on physics, animation, or scripts. A visual editor, rare for the mid-2000s, meant you could just drag things around with a mouse. Support for C# plus a simplified UnityScript made scripting approachable. The industry took notice. &lt;/p&gt;

&lt;p&gt;The turning point came in 2008 when Unity shipped on Windows, multiplying its audience tenfold. The real liftoff, though, happened two years later with the Unity Asset Store—a marketplace of ready-made models, textures, and scripts, most of it a dollar or free, which was manna from heaven for indie studios and solo developers. At the same time, the engine added iOS and Android support, right as smartphones exploded. Suddenly, one laptop and a good idea felt like enough to build a game. That's how Temple Run (2011) and Monument Valley (2014) came to be. EA, Blizzard, and Ubisoft followed in 2011, signing long-term support deals and licensing the source code for internal use. By 2015, nearly half of mobile developers were using Unity. &lt;/p&gt;

&lt;p&gt;The internals still resembled a large patchwork quilt: three different build systems, a pile of reinvented wheels, a partially modified EASTL library sitting alongside Boost and the standard C++ library. Different parts of the engine could use different STL versions, which meant copying data at the boundaries, for example, between the renderer that used EASTL and the editor which had its own custom classes and containers. &lt;/p&gt;

&lt;p&gt;Tack on Mono with its own data exchange layer and you end up with a classic game engine architecture of the early 2000s. Not to be too uncharitable, I call this kind of architecture "unitary". &lt;/p&gt;

&lt;p&gt;You may have heard the saying that programming languages come in two kinds: the ones people complain about, and the ones nobody uses. This analogy seems to fit here. For what it's worth, I have genuine respect for this engine, so don't let any of the above mislead you. &lt;/p&gt;

&lt;h2&gt;
  
  
  Big Ball of Mud
&lt;/h2&gt;

&lt;p&gt;Code that grows without structure has a name: Big Ball of Mud, an anti-pattern popularized by Brian Foote in the 1990s. Among my colleagues I've also heard variations like Cup of Mud, Fancy Barrel, and Dirty Feet. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"A Big Ball of Mud is a haphazardly structured, sprawling, sloppy, duct-tape-and-baling-wire, spaghetti-code jungle. These systems show unmistakable signs of unregulated growth, and repeated, expedient repair. Information is shared promiscuously among distant elements of the system, often to the point where nearly all the important information becomes global or duplicated. The overall structure of the system may never have been well defined. If it was, it may have eroded beyond recognition. Programmers with a shred of architectural sensibility shun these quagmires. Only those who are unconcerned about architecture, and, perhaps, are comfortable with the inertia of the day-to-day chore of patching the holes in these failing dikes, are content to work on such systems." &lt;/p&gt;

&lt;p&gt;Brian Foote&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In practice, a "unitary" architecture may describe, for example, a simple game where event handlers are wired directly to handling logic without internal buffering or dispatching. Most games start out that way, and it works fine until it doesn't. For a tiny game with a few mechanics and screens, it's no big deal. But the codebase keeps growing. Without structure, every change turns into an uphill struggle, and sooner or later releases, testing, scalability, and performance all start to hurt. &lt;/p&gt;

&lt;p&gt;This anti-pattern is everywhere. Hardly anyone sets out to create a "unitary" architecture, but poor quality control and a lack of structural discipline will get you there eventually. Within such a system, any change in one class can break something completely unrelated, making every bug fix or tweak a gambling nightmare. At its worst, the project ends up as a jumble of source files, resources, and engine-technical files. &lt;/p&gt;

&lt;p&gt;What started as a three-student project is now maintained by a team of 400 engineers. Unity Technologies employs 5,000 people, fewer than 10% of whom are programmers. Picture 2.1 shows a block diagram of Unity Engine, and there's nothing to worry about at first glance... Until you dig deeper into the C++ guts and try to change something. &lt;/p&gt;

&lt;p&gt;By this point the "simple" architecture hasn't been simple for a while. Everything talks to everything: managers depend on other managers, states reference one another, events fire when nobody expects them to. Try to fix one thing and two others break. Changing one feature suddenly requires rebuilding half the dependency graph. The longer it goes without cleanup, the scarier the code becomes to touch. The cost of developing new features skyrockets under these conflicts, when you can't say what affected what, and where it's going to blow up. &lt;/p&gt;

&lt;p&gt;Components never designed for reuse become traps for anyone new to the codebase. With no clear boundaries, dependencies, or isolation, reliability decreases. As a result, developers grow afraid to make changes, and the project stagnates. Picture 2.1 shows an overview of the Unity engine (version 4, 2014), and Picture 2.2 shows a class-dependency diagram where each chord represents a relationship between the classes and subsystems shown in Picture 2.1. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiyaf8mzacfdmyoximpe9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiyaf8mzacfdmyoximpe9.png" alt="1384_chapter_1_pt_3/image2.png" width="800" height="1055"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picture 2.1&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4rgzyva7rrp1el4w8vsl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4rgzyva7rrp1el4w8vsl.png" alt="1384_chapter_1_pt_3/image3.png" width="400" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picture 2.2&lt;/p&gt;

&lt;p&gt;The Cup of Mud architecture (or a legacy bog) describes localized pockets of mess inside an otherwise orderly codebase. Individual functions, classes, or modules become islands of chaos: a function may have dozens of parameters, multiple nested conditions, and mixed logic from different levels of abstraction. These spots usually start as temporary fixes or emergency patches that nobody ever got around to cleaning up. Smaller in scale than a Big Ball of Mud, these pockets still breed bugs and slow development down, as developers avoid touching them. &lt;/p&gt;

&lt;p&gt;Fancy Barrel is about code with a clean, attractive API that hides chaotic, poorly organized internals. It boasts good documentation, elegant method names, and modern design patterns on the surface, while the architecture remains tangled and unstructured. A beautiful facade that conceals a "barrel" of technical debt and creates a false impression of quality engineering. The problem surfaces the moment you need to extend something or fix a bug. At that point the pretty interface is all you have to show for it. &lt;/p&gt;

&lt;p&gt;Dirty Feet ("as if someone has tracked mud through the whole house") and Pigsty both describe code that has left a mess scattered across the system. The hallmark is broken encapsulation, where changes in one module force modifications in dozens of seemingly unrelated components. Anyone working in this codebase ends up poking around in unrelated corners of the system to implement a single feature, eroding logic and building up hidden dependencies. The result is code that's hard to test and even harder to isolate, as every component drags in a pile of side effects and demands complex setup. &lt;/p&gt;

&lt;h2&gt;
  
  
  Unreal Engine (Layered Architecture)
&lt;/h2&gt;

&lt;p&gt;In 1991, Tim Sweeney, the founder of Epic Games (at the time just Epic MegaGames), started building editing tools for his first titles. It all began with a top-down adventure-puzzle game called ZZT, with bare-bones graphics (Picture 2.3). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmt8b2h19sp3p8uophy3m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmt8b2h19sp3p8uophy3m.png" alt="1384_chapter_1_pt_3/image4.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picture 2.3&lt;/p&gt;

&lt;p&gt;Players explored maze-like levels, fought enemies, and solved small puzzles, all rendered in plain ASCII characters in DOS text mode. ZZT was never going to turn heads for its graphics or gameplay at the time, but Tim's approach to programming—and especially the built-in ZZT-OOP level editor—established the modularity principles that later evolved into Unreal Engine. &lt;/p&gt;

&lt;p&gt;ZZT proved successful, bringing its author about $100 a day in shareware sales. Enough to convince Sweeney that game development might actually be a real career instead of a hobby. Hiring a small team from a level-design contest for ZZT, he moved the business out of his parents' house, and a five-person team got to work on the next project—Jill of the Jungle. In 1992, Epic shipped Jill of the Jungle (Picture 2.4), a DOS platformer that introduced more advanced tools such as sprite animation, movement physics, and particles. The bigger shift was a growing emphasis on a component-based approach: Tim built objects from data structures based on standard engine components, making it possible to override object behavior without touching the rest of the code. You could create new enemy types, change their AI, or add interactive level elements through scripts. &lt;/p&gt;

&lt;p&gt;At a time when most studios essentially rebuilt their technology from zero for every game, Tim's approach was different. He separated the game into three distinct layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the engine (low-level systems: rendering, physics, sound); &lt;/li&gt;
&lt;li&gt;the content (assets and base logic);&lt;/li&gt;
&lt;li&gt;the scripts (configuration files and high-level logic).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those ideas grew into something bigger. In 1998, Epic released the first version of Unreal Engine alongside the game Unreal. &lt;/p&gt;

&lt;p&gt;The structure of the first engine-game looked more disciplined—rendering, shared systems, scripting, tools, and editing workflows existed as relatively independent pieces. On top sat UnrealEd, while gameplay logic leaned on UnrealScript, an object-oriented scripting language with class inheritance that made modding significantly more accessible. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpna8qrxbl19rugy1poo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpna8qrxbl19rugy1poo.png" alt="1384_chapter_1_pt_3/image5.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picture 2.4&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1samw4jm8at5xjt5i44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1samw4jm8at5xjt5i44.png" alt="1384_chapter_1_pt_3/image6.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picture 2.5&lt;/p&gt;

&lt;p&gt;Other technical advances followed: dynamic collision, 16-bit color, richer lighting, and tools that let developers run and tweak parts of the game directly in the level editor. The game was a hit, selling over 1.5 million copies. In 1999 Epic released its second game, Unreal Tournament, which was a "lessons learned" exercise that added built-in networking support to the engine. &lt;/p&gt;

&lt;p&gt;In 2002, Epic released Unreal Engine 2, debuting publicly alongside America's Army—a free multiplayer shooter built to boost public interest in military service. It was the first time the army had used large-scale game technology for a public audience; the game picked up several player-voted awards along the way. &lt;/p&gt;

&lt;p&gt;Although Epic's primary focus remained PC game development, Sweeney and his team once again recognized where the market was heading: toward consoles. The idea of creating a single engine that would allow developers to release games on both PCs and the Sony PlayStation 2, Nintendo GameCube, and Microsoft Xbox was highly appealing. Unreal Engine 2 also reflected Sweeney's interest in modularity—unlike many competitors of the era, Epic avoided treating each engine release as a frozen artifact. So, after its first drop in 2002, the engine was regularly updated and modified. &lt;/p&gt;

&lt;p&gt;Flexibility became another key pillar of Unreal Engine 2. While previous engines from other companies were mostly locked to a single genre—first-person shooters—the Epic team recognized that giving developers the freedom to work across genres would be a huge competitive edge. Integrating the Karma physics engine, a particle system, and other new capabilities quickly turned UE2 into an industry standard, powering titles such as BioShock and Thief: Deadly Shadows. &lt;/p&gt;

&lt;p&gt;Unreal Engine 3 shipped in 2006, with the first Gears of War as its flagship. The engine's growing platform support opened the door to iOS and Android releases. This update was aimed more at the player-facing side of things—the internal architecture stayed largely unchanged, but the renderer got a significant overhaul: per-pixel lighting, better physics, and much more. &lt;/p&gt;

&lt;p&gt;Game developers often rely on layered architecture to keep their codebase well-organized. Even though Unreal Engine was shaped by one specific person's vision for a long time, it scaled well to a large team, giving the engine and its subsystems both structure and room to grow. &lt;/p&gt;

&lt;p&gt;Looking at how the engine's components connect (Picture 2.6), it's clear that while different parts still talk to each other, there are far fewer connections than you might expect. A layered architecture maps naturally onto a component system: scene objects, physics, or scripts—each sitting at its own level of abstraction. This ends up becoming the de facto standard and the architectural foundation for most studios building games on top of the engine. &lt;/p&gt;

&lt;p&gt;Once again, back to Conway's Law, which says that codebase structure tends to mirror the way teams are organized, and Unreal is a textbook example. Its development team is split into focused groups—UI/input, gameplay, AI (responsible for NPCs, interactive objects, and enemies), and a dedicated engine-optimization team. This structure naturally tends to show up in the game teams building with the engine. And yet, individual developers may take on tasks beyond their usual scope or complete internships in other teams—this is just part of how Epic operates. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fik8qri6o35r8jzcwrww0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fik8qri6o35r8jzcwrww0.png" alt="1384_chapter_1_pt_3/image7.png" width="623" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picture 2.6&lt;/p&gt;

&lt;p&gt;People are people, and developing with Unreal can be surprisingly comfortable—comfortable enough that teams sometimes slip into a "default architecture," following the engine's templates and conventions without questioning the reasoning behind them. A project can even drift into a "unitary" architecture, where developers simply start coding without a clear plan. For a while the layered structure the engine provides holds things together, but again, without real discipline behind it, the codebase gradually devolves into a Big Ball of Mud. &lt;/p&gt;

&lt;p&gt;As of 2023, Epic Games has around 4,000 employees worldwide, spanning game teams, publishing, the store, and the engine itself. Open-source estimates put the number of people working directly on the engine somewhere between 500 and well over 1,000. That includes around 200 programmers focused on graphics, physics, and optimization. Beyond them, there are technical support engineers who maintain the GitHub repository and handle incoming commits, as well as technical writers and course engineers. Developers for VR/AR and mobile, and a large division dedicated to Virtual Production, CAD integration, and support for major game and film studios—together adding roughly 400 more people. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Author: Sergei Kushnirenko&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sergei has over 20-year experience in coding and game development. He graduated from ITMO National Research University and began his career developing software for naval simulators, navigation systems, and network solutions. For the past fifteen years, Sergei has specialized in game development: at Electronic Arts, he worked on optimizing The Sims and SimCity BuildIt, and at Gaijin Entertainment, Sergei headed up the porting of games to the Nintendo Switch and Apple TV platforms. Sergei actively participates in open-source projects, including the ImSpinner library and the Pharaoh (1999) game restoration project.&lt;/p&gt;

&lt;h2&gt;
  
  
  All parts
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/1361/" rel="noopener noreferrer"&gt;Game++. Part 1.1: C++, game engines, and architectures&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pvs-studio.com/en/blog/posts/1375/" rel="noopener noreferrer"&gt;Game++. Part 1.2: C++, game engines, and architectures&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>gamedev</category>
      <category>programming</category>
      <category>software</category>
    </item>
    <item>
      <title>Changes to PVS-Studio's student licensing policy</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Mon, 15 Jun 2026 12:16:53 +0000</pubDate>
      <link>https://dev.to/pvsdev/changes-to-pvs-studios-student-licensing-policy-4ee2</link>
      <guid>https://dev.to/pvsdev/changes-to-pvs-studios-student-licensing-policy-4ee2</guid>
      <description>&lt;p&gt;We have updated the licensing terms regarding the free use of the tool by students and teachers. Here is a breakdown of the changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2orgd58dprqf5d0psc0d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2orgd58dprqf5d0psc0d.png" alt="1383_academic_license_update/image1.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A couple of months ago, we &lt;a href="https://pvs-studio.com/en/blog/posts/1362/?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=article&amp;amp;utm_content=1383" rel="noopener noreferrer"&gt;discussed&lt;/a&gt; changes to PVS-Studio's free licensing policy and mentioned our plans to update the process of obtaining licenses for students and teachers. The update is finally complete, and here's how everything works now.&lt;/p&gt;

&lt;p&gt;To obtain a student license, select the Student License option in the &lt;a href="https://pvs-studio.com/en/pvs-studio/try-free/?license_type=academic&amp;amp;utm_source=website&amp;amp;utm_medium=devto&amp;amp;utm_campaign=article&amp;amp;utm_content=1383" rel="noopener noreferrer"&gt;trial key request form&lt;/a&gt; and submit the request using your university email address (with the university domain). Upon request, we will issue you a temporary one-month license.&lt;/p&gt;

&lt;p&gt;You can learn more about PVS-Studio's student licensing terms &lt;a href="https://pvs-studio.com/en/order/for-students/?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=article&amp;amp;utm_content=1383" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In addition, you can use the &lt;a href="https://godbolt.org/" rel="noopener noreferrer"&gt;Compiler Explorer&lt;/a&gt; website, which allows you to write, compile, and run programs in various programming languages online. You can check C and C++ code &lt;a href="https://pvs-studio.com/en/pvs-studio/examples/?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=article&amp;amp;utm_content=1383" rel="noopener noreferrer"&gt;using PVS-Studio&lt;/a&gt; directly from the platform interface. &lt;/p&gt;

&lt;p&gt;You can also get a free license for open-source projects. For more information, follow &lt;a href="https://pvs-studio.com/en/order/open-source-license/?utm_source=devto&amp;amp;utm_medium=pvs&amp;amp;utm_campaign=article&amp;amp;utm_content=1383" rel="noopener noreferrer"&gt;this link&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>product</category>
      <category>news</category>
    </item>
    <item>
      <title>Error that we had to ignore</title>
      <dc:creator>Unicorn Developer</dc:creator>
      <pubDate>Fri, 05 Jun 2026 13:23:12 +0000</pubDate>
      <link>https://dev.to/pvsdev/error-that-we-had-to-ignore-dc</link>
      <guid>https://dev.to/pvsdev/error-that-we-had-to-ignore-dc</guid>
      <description>&lt;p&gt;Developing a static analyzer, as with any software project, involves trade-offs. Sometimes this means dropping perfectly valid analyzer warnings to make the tool better overall. In the article, we'll look at a real-life example of that kind of compromise. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9laa0ng82dk3trgu297b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9laa0ng82dk3trgu297b.png" alt="1381_warning_loss/image1.png" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;For the context, we're actively developing a static code analyzer for JavaScript and TypeScript, which is currently in beta (and we'd love for you to &lt;a href="https://pvs-studio.com/en/pvs-studio-eap/" rel="noopener noreferrer"&gt;join&lt;/a&gt; it). &lt;/p&gt;

&lt;p&gt;But back to the point: I've been working on the &lt;a href="https://pvs-studio.com/en/docs/warnings/v7001/" rel="noopener noreferrer"&gt;V7001&lt;/a&gt; diagnostic rule, which detects typos in the form of identical operands in binary expressions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;let&lt;/span&gt; &lt;span class="n"&gt;baz&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt; &lt;span class="err"&gt;–&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt; &lt;span class="c1"&gt;// foo - bar&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;foo&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// foo == bar&lt;/span&gt;
  &lt;span class="c1"&gt;// ....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also focuses on more complex cases like nested expressions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And expressions that are not identical but equivalent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're curious about how our JavaScript diagnostic rules perform in practice, we've covered some findings from open-source projects in the separate &lt;a href="https://pvs-studio.com/en/blog/posts/js/1363/#ID68AC3AA657" rel="noopener noreferrer"&gt;article&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  More noise than signal
&lt;/h2&gt;

&lt;p&gt;Right after I finished writing this diagnostic rule, I ran analysis on our &lt;a href="https://pvs-studio.com/en/blog/posts/js/1363/#ID79DE99F61B" rel="noopener noreferrer"&gt;project database&lt;/a&gt; and found this code snippet in &lt;a href="https://github.com/mozilla/pdf.js/" rel="noopener noreferrer"&gt;pdf.js&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="nl"&gt;flagValues:&lt;/span&gt; &lt;span class="n"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;freeze&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nl"&gt;applyOverPrint:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;applySoftProofSettings:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;applyWorkingColorSpaces:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;emitHalftones:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;emitPostScriptXObjects:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;emitFormsAsPSForms:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;maxJP2KRes:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;setPageSize:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;suppressBG:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;suppressCenter:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;suppressCJKFontSubst:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;suppressCropClip:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;suppressRotate:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;suppressTransfer:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;suppressUCR:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;useTrapAnnots:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;usePrintersMarks:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code defines a set of conversion flags used to control printing. Each flag represents a single option, and the flags can be freely combined using bitwise operations. The flags are grouped by categories: color correction, transformation suppression, fonts, and so on. However, there's something off in this code. See that?&lt;/p&gt;

&lt;p&gt;The PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v7001/" rel="noopener noreferrer"&gt;V7001&lt;/a&gt; The operands of the '&amp;lt;&amp;lt;' operator in the '1 &amp;lt;&amp;lt; 1' expression are equivalent. &lt;a href="https://github.com/mozilla/pdf.js/blob/25c7d9eaace0438316714aff7033dd5f4c1a542e/src/scripting_api/print_params.js#L90" rel="noopener noreferrer"&gt;print_params.js 90&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The warning points to the line between the 10th and 12th flags:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="nl"&gt;suppressCJKFontSubst:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;suppressCropClip&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;suppressRotate&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Perhaps, this code is a child of Ctrl+C and Ctrl+V, with the field name and flag number changed manually in each line. But in one place, &lt;code&gt;1 &amp;lt;&amp;lt; 1&lt;/code&gt; was never replaced with &lt;code&gt;1 &amp;lt;&amp;lt; 11&lt;/code&gt;. One digit missing among a sea of ones, no wonder it could go unnoticed.&lt;/p&gt;

&lt;p&gt;This code has just been added and isn't called anywhere yet, so it doesn't cause any issues. And yet, when the time comes, &lt;code&gt;applySoftProofSettings&lt;/code&gt; and &lt;code&gt;suppressCropClip&lt;/code&gt; will behave as a single flag. All in all, this is a good catch for the analyzer, it found a real error here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hide the pain Harold
&lt;/h3&gt;

&lt;p&gt;However, if you run PVS-Studio for JavaScript or TypeScript today, you won't see this warning. Why? While we were developing this diagnostic rule, the analyzer output &lt;strong&gt;a huge&lt;/strong&gt; number of similar warnings—but the vast majority of them looked like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;opi=89978449&amp;amp;url=https://github.com/angular/angular&amp;amp;ved=2ahUKEwi-6JquuMqUAxW-gf0HHcevJbIQFnoECA4QAQ&amp;amp;usg=AOvVaw1tvULFkP3fqqpks94a3f2q" rel="noopener noreferrer"&gt;Angular&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="n"&gt;InputFlags&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;None&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;SignalBased&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;HasDecoratorInputTransform&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v7001/" rel="noopener noreferrer"&gt;V7001&lt;/a&gt; The operands of the '&amp;lt;&amp;lt;' operator in the '1 &amp;lt;&amp;lt; 1' expression are equivalent. core.ts 49&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;opi=89978449&amp;amp;url=https://github.com/babel/babel&amp;amp;ved=2ahUKEwi6mei1uMqUAxVs8LsIHVAGMBQQFnoECA4QAQ&amp;amp;usg=AOvVaw17APTqb3HJkkAI0IarYX1Z" rel="noopener noreferrer"&gt;Babel&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="n"&gt;PRINTER_FLAGS&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;EMPTY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;PRESERVE_FORMAT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;COMPACT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;CONCISE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;RETAIN_LINES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;RETAIN_FUNCTION_PARENS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;AUX_COMMENTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v7001/" rel="noopener noreferrer"&gt;V7001&lt;/a&gt; The operands of the '&amp;lt;&amp;lt;' operator in the '1 &amp;lt;&amp;lt; 1' expression are equivalent. index.ts 10&lt;/p&gt;

&lt;p&gt;Here's &lt;a href="https://github.com/mozilla/pdf.js/" rel="noopener noreferrer"&gt;pdf.js&lt;/a&gt; again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ON_CURVE_POINT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;X_SHORT_VECTOR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Y_SHORT_VECTOR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;REPEAT_FLAG&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;OVERLAP_SIMPLE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PVS-Studio warning: &lt;a href="https://pvs-studio.com/en/docs/warnings/v7001/" rel="noopener noreferrer"&gt;V7001&lt;/a&gt; The operands of the '&amp;lt;&amp;lt;' operator in the '1 &amp;lt;&amp;lt; 1' expression are equivalent. glyf.js 17&lt;/p&gt;

&lt;p&gt;These are just 3 out of 42 similar warnings among the total number of the &lt;a href="https://pvs-studio.com/en/docs/warnings/v7001/" rel="noopener noreferrer"&gt;V7001&lt;/a&gt; warnings (126) in the test database. As you can see, the analyzer flags &lt;code&gt;1 &amp;lt;&amp;lt; 1&lt;/code&gt; everywhere it appears Technically, it's not wrong: shifting a number by 1 &lt;em&gt;rarely&lt;/em&gt; makes sense outside of very niche scenarios. The result of the &lt;code&gt;1 &amp;lt;&amp;lt; 1&lt;/code&gt; operation will always be &lt;code&gt;2&lt;/code&gt;. And the only thing the notation does is make the interpreter fold the constant during compilation into machine code.&lt;/p&gt;

&lt;p&gt;But here we're dealing with bit flags, where readability and consistency matter more than abstract performance gains. That's the reason why developers usually arrange bit flags into a clean, sequential list with the flag numbers on each line—after all, the overhead from the extra operation is truly negligible.&lt;/p&gt;

&lt;p&gt;Interestingly, the analyzer will also fire a false positive on &lt;code&gt;1 &amp;lt;&amp;lt; 1&lt;/code&gt; in the code snippet provided earlier—yet another strike against such a pattern.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="nl"&gt;applyOverPrint:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;applySoftProofSettings&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;applyWorkingColorSpaces&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we add the case of &lt;code&gt;1 &amp;lt;&amp;lt; 1&lt;/code&gt; to the exceptions, exactly &lt;strong&gt;one third&lt;/strong&gt; of all warnings in our test database disappear, all of which are guaranteed to be false, except for the single real case shown at the beginning. In other words, implementing an exception for &lt;code&gt;1 &amp;lt;&amp;lt; 1&lt;/code&gt; improves this rule by a third.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unsound static analysis
&lt;/h3&gt;

&lt;p&gt;Our development team follows a deliberate approach to warning reliability: we'd rather limit the number of warnings than risk flooding users with noise. It's called an &lt;em&gt;unsound strategy&lt;/em&gt;. Here's a quote from our &lt;a href="https://pvs-studio.com/en/blog/posts/cpp/1302/" rel="noopener noreferrer"&gt;article&lt;/a&gt; on taint analysis:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;There are sound and unsound static analysis strategies. Usually, the analyzer operates with an unsound strategy and issues warnings only if it &lt;strong&gt;can prove an error exists&lt;/strong&gt;. Under this strategy, the example above won't trigger a warning about the array index out of bounds.&lt;/p&gt;

&lt;p&gt;The sound strategy follows the opposite principle: the analyzer issues a warning if it &lt;strong&gt;can't prove the absence of an error&lt;/strong&gt;. The main problem with this strategy is the high number of false positives.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To keep the analyzer from generating hundreds or thousands of &lt;a href="https://pvs-studio.com/en/blog/terms/6461/" rel="noopener noreferrer"&gt;false positives&lt;/a&gt;, we have to delve into existing approaches and make heuristic exceptions for them. That's how the exception for &lt;code&gt;1 &amp;lt;&amp;lt; 1&lt;/code&gt; made its way into &lt;a href="https://pvs-studio.com/en/docs/warnings/v7001/" rel="noopener noreferrer"&gt;V7001&lt;/a&gt;, even though it meant sacrificing a valid warning.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why not make a more precise exception?
&lt;/h3&gt;

&lt;p&gt;We could try to design something brighter. For example, checking whether there are any other bit flags nearby. But what does &lt;em&gt;nearby&lt;/em&gt; mean for the static code analyzer? The analyzer works with a syntax tree, and we could try searching for neighbors within the same enumeration:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx8rleqpvmyix8lwrs4a0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx8rleqpvmyix8lwrs4a0.png" alt="1381_warning_loss/image2.png" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But, first, it's easy to &lt;em&gt;trick&lt;/em&gt; such heuristics if we:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;add an extra node to the tree (a function call, an arithmetic expression, etc.);&lt;/li&gt;
&lt;li&gt;change the order of flag declarations;&lt;/li&gt;
&lt;li&gt;store the flags in temporary variables.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In each of these cases, the analyzer will either fail to detect the actual error or start generating false positives again, returning to the very problem we were trying to solve.&lt;/p&gt;

&lt;p&gt;Second, note that the above warnings appeared in three different contexts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;in &lt;code&gt;enum&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;in the initialization of a field within an object expression;&lt;/li&gt;
&lt;li&gt;in constant variables.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's not counting exotic scenarios like bit flags stored in class fields. There are many such cases, especially in JavaScript/TypeScript, and they're very easy to overlook. &lt;/p&gt;

&lt;p&gt;Third, even if we manage to cover all of them at the cost of significantly bloating the code for the rule, there is no guarantee that the heuristics won't deprecate with any future language update. After all, new syntax constructs can simply break it.&lt;/p&gt;

&lt;p&gt;So yes, sometimes we have to make a tough call and sacrifice a good warning in favor of a better analyzer's reliability. Plus, this case gave us the idea to create a separate diagnostic rule for identifying errors in bit flag definition :)&lt;/p&gt;

&lt;h2&gt;
  
  
  Afterword
&lt;/h2&gt;

&lt;p&gt;I hope this gave you a peek into the day-to-day work of developing static analyzers and maybe shed some light on how such tools evolve, and on the compromises that come with improving them. If you've ever faced similar dilemmas in software development, feel free to share them in the comments—I'd love to hear your stories :)&lt;/p&gt;

&lt;p&gt;To stay updated on new articles about code quality, you can subscribe to our monthly &lt;a href="https://pvs-studio.com/en/subscribe/" rel="noopener noreferrer"&gt;newsletter&lt;/a&gt; or follow my personal &lt;a href="https://x.com/kvolokhovskii" rel="noopener noreferrer"&gt;blog&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>software</category>
    </item>
  </channel>
</rss>
