This diagnostic rule is based on the MISRA (Motor Industry Software Reliability Association) software development guidelines.
This diagnostic rule is relevant only for C++.
The analyzer has detected a code fragment where string literals with different encoding prefixes are automatically concatenated.
Using different prefixes when concatenating string literals causes a data type conflict between the string elements (for example, char and wchar_t). The compiler cannot correctly determine the final type and size of the resulting literal. Depending on the build settings, this results in either a compilation error or undefined behavior due to incorrect type conversion, which completely distorts the byte representation of characters in memory.
The example:
const wchar_t *banner = "Hello," L" world";
When string literals without a prefix are concatenated with string literals prefixed with L, the data types conflict, preventing the compiler from safely constructing a single literal.
The fixed code:
const wchar_t *banner = L"Hello," L" world";
This diagnostic rule is classified as:
|
Was this page helpful?