-
Type:
Bug Detection
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Default Severity:Major
-
Impact:Low
-
Likelihood:High
-
Default Quality Profiles:Sonar way
-
Legacy Key:NarrowAndWideStringConcat
-
Covered Languages:C, C++, Objective-C
-
Remediation Function:Constant/Issue
-
Constant Cost:15min
-
CERT:STR10-C.
-
MISRA C++ 2008:2-13-5
-
PC-Lint:707, 1707
Concatenation of wide and narrow string literals leads to undefined behavior.
Noncompliant Code Example
wchar_t n_array[] = "Hello" L"World"; // Noncompliant wchar_t w_array[] = L"Hello" "World"; // Noncompliant
Compliant Solution
char_t n_array[] = "Hello" "World"; // Compliant wchar_t w_array[] = L"Hello" L"World"; // Compliant
See
- MISRA C++:2008, 2-13-5 - Narrow and wide string literals shall not be concatenated.
- CERT STR10-C. - Do not concatenate different type of string literals
1.
|
C-Family | RSPEC-4386 |
|
Active | Unassigned |