文件
Paze AI 251ee470bf feat: Paze C Compiler - 完整改造自 tcc 0.9.28rc
- 所有 tcc 文件/内容/宏改名为 pcc (tcc.c->pcc.c, tccelf.c->pccelf.c, libtcc.c->libpcc.c 等)
- 支持架构: i386, x86_64, ARM, ARM64, RISC-V, C67
- 支持格式: PE, ELF, Mach-O, COFF
- 完整预处理、代码生成、链接器、调试信息
- 构建成功: pcc.exe (x86_64 Windows)
- 功能测试通过: 递归/结构体/浮点/switch/循环
- 自编译测试通过: pcc 可以编译自身
2026-08-16 13:30:01 +08:00

95 行
2.1 KiB
C

#include <stdio.h>
struct big_struct { char a[262144]; };
static const char str[] = "abcdefghijklmnopqrstuvwxyz";
int
main (void)
{
char *p;
char tmp[100];
int r = 0;
#if defined __TCC_BCHECK__
printf("BOUNDS ON:\n");
#else
printf("BOUNDS OFF:\n");
#endif
if (r != 0)
__builtin_abort();
r = (__builtin_offsetof(struct big_struct, a) != 0);
printf(" 1:%d", !r);
p = __builtin_memcpy (tmp, str, sizeof(str));
r = (p != tmp);
printf(" 2:%d", !r);
r = __builtin_memcmp (p, str, sizeof(str));
printf(" 3:%d", !r);
p = __builtin_memmove(tmp, str, sizeof(str));
r = (__builtin_memcmp (p, str, sizeof(str)));
printf(" 4:%d", !r);
p = __builtin_memset(tmp, 0, sizeof (tmp));
r = (p != tmp || tmp[0] != 0 || tmp[99] != 0);
printf(" 5:%d", !r);
r = (__builtin_strlen(str) != sizeof(str) - 1);
printf(" 6:%d", !r);
p = __builtin_strcpy(tmp, str);
r = (__builtin_memcmp (p, str, sizeof(str)));
printf(" 7:%d", !r);
p = __builtin_strncpy(tmp, str, sizeof(str));
r = (__builtin_memcmp (p, str, sizeof(str)));
printf(" 8:%d", !r);
r = (__builtin_strcmp (p, str));
printf(" 9:%d", !r);
r = (__builtin_strncmp (p, str, sizeof(str)));
printf(" 10:%d", !r);
tmp[0] = '\0';
p = __builtin_strcat(tmp, str);
r = (__builtin_memcmp (p, str, sizeof(str)));
printf(" 11:%d", !r);
tmp[0] = '\0';
p = __builtin_strncat(tmp, str, __builtin_strlen(str));
r = (__builtin_memcmp (p, str, sizeof(str)));
printf(" 12:%d", !r);
r = (__builtin_strchr(p, 'z') != &p[25]);
printf(" 13:%d", !r);
r = (__builtin_strrchr(p, 'z') != &p[25]);
printf(" 14:%d", !r);
p = __builtin_strdup (str);
r = (__builtin_memcmp (p, str, sizeof(str)));
printf(" 15:%d", !r);
__builtin_free(p);
p = __builtin_malloc (100);
__builtin_memset(p, 0, 100);
p = __builtin_realloc (p, 1000);
__builtin_memset(p, 0, 1000);
__builtin_free(p);
p = __builtin_calloc(10, 10);
__builtin_memset(p, 0, 100);
__builtin_free(p);
#if defined(__i386__) || defined(__x86_64__)
p = __builtin_alloca(100);
__builtin_memset(p, 0, 100);
#endif
printf("\n");
}