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.IMPSC : Implicit Encoding in String Concatenation

要旨

Some, but not all, of the string literals in a concatenation operation have implicit encoding.

This can make the operation harder for human readers to understand.

See also Mixed Encodings in String Concatenation.

プロパティ

クラス名 Implicit Encoding in String Concatenation
日本語クラス名 Implicit Encoding in String Concatenation
クラス分類 スタイル (style)
ニーモニック LANG.TYPE.IMPSC
カテゴリー
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
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Implicit Encoding in String Concatenation"

#include <string>
using namespace std::string_literals;

const wchar_t * bad1 =   "Hello" L"World";  // 'Implicit Encoding in String Concatenation' warning issued here
const wchar_t * bad2 =  L"Hello"  "World";  // 'Implicit Encoding in String Concatenation' warning issued here

const char * good1 =  "Hello" "World";                   // ok: no explicit encoding
const wchar_t * good2 =  L"Hello" L"World";              // ok: same explicit encoding

// User-defined suffixes do not denote an encoding.
std::string     good3 =  "abc"  "def"s;                  // ok: no explicit encoding
std::wstring    good4 = L"abc" L"def"s;                  // ok: same explicit encoding
std::wstring bad3 = "Hello"s L"World"s;     // 'Implicit Encoding in String Concatenation' warning issued here

// The R prefix denotes a raw string, not an encoding.
const char *    good5 =  "abc" R"(def)";                // ok: no explicit encoding
const wchar_t * good6 = L"abc" LR"(def)";               // ok: same explicit encoding
const wchar_t * bad4 = "Hello" LR"(World)"; // 'Implicit Encoding in String Concatenation' warning issued here

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。

 

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