AutosarC++18_10-A2.3.1

Only those characters specified in the C++ Language Standard basic source character set shall be used in the source code

Required inputs: IR

Rationale

“The basic source character set consists of 96 characters: the space character, the control characters representing horizontal tab, vertical tab, form feed, and new-line, plus the following 91 graphical characters: a b c d e f g h i j k l m n o p q r s t u v w x y zABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_{}[]#( ) < > % : ; . ? * + - / ^ & | ~ ! =, \ " ’ ” [C++ Language Standard [3]]

Exceptions

It is permitted to use other characters inside the text of a wide string and a UTF-8 encoded string literal.

It is also permitted to use a character @ inside comments. See rule A2-7-3.

Example
// $Id: A2-3-1.cpp 307578 2018-02-14 14:46:20Z michal.szczepankiewicz $
    #include <cstdint>

    void Fn() noexcept
    {
        std::int32_t sum = 0; // Compliant
        // std::int32_t £_value = 10; // Non-compliant
        // sum += £_value; // Non-compliant
        // Variable sum stores £ pounds // Non-compliant
    }
See Also
  • JSF December 2005 [8]: AV Rule 9: Only those characters specified in the C++ basic source character set will be used.

Possible Messages

Key

Text

Severity

Disabled

forbidden_characters

Forbidden characters used.

None

False

Options

allow_in_comments

allow_in_comments : bool = False

Whether to allow characters not in the basic source character set in comments.
 

allow_in_unicode_strings

allow_in_unicode_strings : bool = True

Whether to allow characters not in the basic source character set in unicode string literals.
 

allow_in_wide_strings

allow_in_wide_strings : bool = True

Whether to allow characters not in the basic source character set in wide string literals.
 

basic_characters_list

basic_characters_list

Type: str

Default: ' \t\v\f\r\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_\{\}\[\]\#\(\)<>%:;\.\?\*\+\-/\^\&\|\~!=,\\'"\(\)@'

The basic character list as per rule.