JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++


LANG.TYPE.MIXSC : Mixed Encodings in String Concatenation

Summary

The string literals in a concatenation operation have different encodings.

See also Implicit Encoding in String Concatenation.

Properties

Class Name Mixed Encodings in String Concatenation
Significance style
Mnemonic LANG.TYPE.MIXSC
Categories
AUTOSARC++14 AUTOSARC++14:A2-13-2 String literals with different encoding prefixes shall not be concatenated.
MisraC++2008 MisraC++2008:2-13-5 Narrow and wide string literals shall not be concatenated.
MisraC++2023 MisraC++2023:5.13.7 Strings with different encoding prefixes shall not be concatenated
CERT-C CERT-C:STR10-C Do not concatenate different type of string literals
Availability Available for C and C++.
Enabling Checks for this warning class are enabled by default. However, warning instances of this class that are issued as parser errors (rather than parser warnings) will be discarded when using factory configuration settings. To prevent these instances from being discarded, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="Mixed Encodings in String Concatenation"
To disable checks for this warning class, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Mixed Encodings in String Concatenation"

Example

#include <cstddef>

// The code in this file will typically cause compiler errors.

// 'u' and 'U' literals introduced in C++11
#if __cplusplus >= 201103L

auto bad1 = u"abc" L"def";  // 'Mixed Encodings in String Concatenation' warning issued here
                            // for C++11 and later

auto bad2 = U"abc" L"def";  // 'Mixed Encodings in String Concatenation' warning issued here
                            // for C++11 and later

const char * bad3 = u8"abc" L"def"; // 'Mixed Encodings in String Concatenation' warning issued here

#endif

const wchar_t * good1 = "abc" L"def";   // ok: not a mixed encoding
                                        // ('Implicit Encoding in String Concatenation' warning issued when enabled)

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.

 

To report problems with this documentation, please visit https://support.codesecure.com/.