Skip to content

RULE-6-9-2 / A3-9-1: False positives for variables declared with auto that deduce to fixed-width types #1145

Closed

Description

@castler

Affected rules

  • RULE-6-9-2
  • A3-9-1

Description

RULE-6-9-2 ("The names of the standard integer types should not be used") and AUTOSAR A3-9-1 share the query logic in VariableWidthIntegerTypesUsed.qll. The rule's intent is to prevent programmers from explicitly using variable-width integer type names (e.g., int, unsigned long) in declarations. Instead, fixed-width types from <cstdint> (e.g., std::uint32_t, std::int64_t) should be used.

The query currently produces false positives for variables declared with auto or decltype(auto) when the deduced type resolves through a fixed-width typedef to a built-in integer type. In these cases, the programmer never explicitly wrote a variable-width type name — they used auto, and the type was deduced from context (e.g., from a function returning std::uint32_t).

Example

using ID= std::uint32_t;

std::optional<ID> get_context_id();

void process() {
    const auto id = get_context_id();
    const auto value = id.value();  // Flagged: "Variable 'value' has variable-width type."
}

Activity

  1. added a commit that references this issue on Jul 19, 2026
    4ca4133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    false positive/false negativeAn issue related to observed false positives or false negatives.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions