Skip to content

UB26⚓︎

Author: Tianlin Xiao.

Content⚓︎

An unmatched ’ or " character is encountered on a logical source line during tokenization (6.4)

Description⚓︎

当在一个逻辑行中出现了未匹配的'"字符串时,结果未定义。逻辑行:可以使用反斜杠符号\来连接物理行以创建逻辑行。当一行代码太长无法适合单个物理行时,可以使用反斜杠符号将其连接到下一行,以形成一个逻辑行。例如:

#include <stdio.h>

int main() {
    int a = 5, b = 10, c = 15, d = 20;
    int sum = a + b + \
              c + d;
    printf("Sum = %d", sum);
    return 0;
}

Code⚓︎

#include<stdio.h>
#include "string.h


int main()
{
    printf("Hello");
    return 0;
}

Configuration⚓︎

Configuration 1.⚓︎

tcc version 0.9.26 (x86-64 Win64)

Configuration 2.⚓︎

gcc version 8.1.0 
Target: x86_64-w64-mingw32

Result of Different Configuration⚓︎

Configuration 1.⚓︎

- Compilation successful
- Hello

Configuration 2.⚓︎

main.c:2:10: warning: missing terminating " character
 #include "string.h
          ^
main.c:2:10: error: #include expects "FILENAME" or <FILENAME>
 #include "string.h