Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V2677. MISRA. String literals with...
menu mobile close menu
Additional information
toggle menu Contents

V2677. MISRA. String literals with different encoding prefixes should not be concatenated.

Jul 30 2026

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";

What a quick draw in the Wild West of Coding —
you caught the bug in sec!
But we catch them in milliseconds. How about a duel?

Try free