V638. Terminal null is present inside a string. Use of '\0xNN' characters. Probably meant: '\xNN'.
The analyzer has detected a potential error: there is a terminal null character inside a string.
This error usually occurs through a misprint. For example, the "\0x0A" sequence is considered by the program as a sequence of four bytes: { '\0', 'x', '0', 'A' }.
If you want to define the character code in the hexadecimal form, the 'x' character should stand right after the '\' character. If you write "\0", the program will consider it as zero (in the octal format). See also:
- MSDN. C Character Constants.
- MSDN. Escape Sequences.
Consider an example of incorrect code:
const char *s = "string\0x0D\0x0A";
If you try to print this string, the control characters intended to translate the string will not be used. The output functions will stop at the line-end character '\0'. To fix this bug you should replace "\0x0D\0x0A" with "\x0D\x0A".
This is the fixed code:
const char *s = "string\x0D\x0A";
This diagnostic is classified as:
You can look at examples of errors detected by the V638 diagnostic. |