According to \[[MISRA 08|AA. C References#MISRA 08]\], concatenation of wide and narrow string literals leads to undefined behavior. |
This noncompliant code example concatenates wide and narrow string literals. The behavior is undefined in this case.
wchar_t *msg = L"This message is very long, so I want to devide it "
"into two parts.";
|
This compliant solution concatenates wide string literals only.
wchar_t *msg = L"This message is very long, so I want to devide it "
L"into two parts.";
|
If wide string literals are not necessary, it is better to use narrow string literals.
char* msg = "This message is very long, so I want to devide it "
"into two parts.";
|
Concatenation of wide and narrow string literals leads to undefined behavior.
Rule |
Severity |
Likelihood |
Remediation Cost |
Priority |
Level |
|---|---|---|---|---|---|
ENV30-C |
low |
probable |
medium |
P4 |
L3 |
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
\[[MISRA 08|AA. C References#MISRA 08]\] Rule 2-13-5 \[[ISO/IEC 14882-2003|AA. C References#ISO/IEC 14882-2003]\] 2.13.4 String literals |