SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • ShellShell
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
C

C static code analysis

Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your C code

  • All rules 420
  • Vulnerability14
  • Bug111
  • Security Hotspot19
  • Code Smell276

  • Quick Fix 27
Filtered: 3 rules found
misra-directive
    Impact
      Clean code attribute
        1. A function call shall not violate the function's preconditions

           Bug
        2. Floating-point arithmetic should be used appropriately

           Bug
        3. Sections of code should not be "commented out"

           Code Smell

        Floating-point arithmetic should be used appropriately

        intentionality - logical
        reliability
        Bug
        • unpredictable
        • misra-c++2023
        • misra-advisory
        • misra-directive

        Why is this an issue?

        More Info

        This rule is part of MISRA C++:2023.

        Usage of this content is governed by Sonar’s terms and conditions. Redistribution is prohibited.

        Dir 0.3.1 - Floating-point arithmetic should be used appropriately

        [ISO/IEC/IEEE 60559]

        Category: Advisory

        Amplification

        A tool should highlight all suspicious uses of floating-point arithmetic.

        Rationale

        The safe use of floating-point arithmetic requires a high level of numerical analysis skills and in-depth knowledge of the compiler and target hardware.

        The incorrect use of floating-point may lead to problems related to the presence of positive and negative zero, loss of precision, NaNs (quiet and signalling), infinities, overflow, underflow, catastrophic cancellation, etc.

        Example

        bool myIsNaN( double d )
        {
          return d == std::numeric_limits< double >::quiet_NaN();  // Always returns false
        }
        
        void f()
        {
          float f1 = 1E38f;
          float f2 = 10.0f;
          float f3 = 0.1f;
          float f4 = ( f1 * f2 ) * f3;
          float f5 = f1 * ( f2 * f3 );   // Values in f4 and f5 are significantly different
        }
        

        Copyright The MISRA Consortium Limited © 2023

          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube ServerAnalyze code in your
          on-premise CI

        © 2025 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use