AutosarC++19_03-A2.13.2¶
String literals with different encoding prefixes shall not be concatenated
Required inputs: IR
Bad code (mixing narrow and wide strings):
const char* msg = "Hello" L"World"; // ERROR: narrow + wide concatenation const wchar_t* wstr = L"Part1" "Part2"; // ERROR: wide + narrow
Good code (consistent narrow strings):
const char* msg = "Hello" "World"; // OK: both narrow // Result: "HelloWorld"
Good code (consistent wide strings):
const wchar_t* msg = L"Hello" L"World"; // OK: both wide // Result: L"HelloWorld"
Good code (separate handling):
const char* narrow = "Hello"; const wchar_t* wide = L"World"; // Handle separately with proper string operations
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
mixed_string_concatenation |
Concatenation of mixed string encodings |
None |
False |
narrow_wide_concat |
Concatenation of narrow and wide string literal |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
cpp11_mode¶
cpp11_mode : bool = True
L and unprefixed literals are reported.
If true, prefixes of length two and unprefixed literals are conforming;
but additionally, mixed_string_concatenation compiler messages are reported.
report_all_prefix_differences¶
report_all_prefix_differences : bool = False