毕昇3.0.0 编译Bug
收藏回复举报
毕昇3.0.0 编译Bug
t('forum.solved') 已解决
发表于2023-07-31 22:16:18
0 查看

对于如下代码,毕昇3.0.0 在-O1 优化下编译出错。这个Bug是我们团队的最新自动化编译测试工具最先在LLVM/Clang上找到的,但是我发现毕昇3.0.0是基于LLVM-15的,而我们找到的某些Bug在LLVM-15上也存在,所以我测试了一下毕昇编译器,发现也会出错。

错误如下:

$ bisheng/clang -w -O0 a.c && ./a.out
1
-1
$ bisheng/clang -w -O1 a.c && ./a.out
1
0
$
$ bisheng/clang -v
HUAWEI BiSheng Compiler 3.0.0 clang version 15.0.4 (0070a75ffcba)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/shaoli/compilers/ccbuilder-compilers
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
$

源代码:

int printf(const char *format, ...);
static short d;
long e;
long *g = &e;
int h;
int i(int j) {
  int c = 1;
  for (;; c++)
    if (1 << c >= j)
      return c;
}

void l(int j) {
  int m, o = (j + 83)%12;
  h = -o + 9;
  unsigned n = h;
  m = n >= 32 ? 1 : 1 >> n;
  if (m)
    *g = j;
  short *a = &d, *b = &a;
  b || 0;
}
void p() {
  int q = i(d - 8);
  printf("%d\n", q);
  l(-q);
}
int main() {
  p();
  printf("%ld\n", e);
}

本帖最后由 匿名用户2023/11/16 15:51:50 编辑

我要发帖子