红薯nbsp;57nbsp;个让nbsp;Cnbsp;编译器崩溃的代码

2024-01-12 03:32

本文主要是介绍红薯nbsp;57nbsp;个让nbsp;Cnbsp;编译器崩溃的代码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

我不清楚你是否很高兴看到你的程序会让编译器崩溃的情况,反正我很喜欢,相当于发现了编译器的 bug。

本文列出 57 段代码以及相应的编译器版本和编译参数,在这个环境下对代码进行编译会导致编译器崩溃。

1 : Crashes Clang 2.6 at -O0:

01#pragma pack(1)
02struct S1 {
03  int f0;
04  char f2
05};
06struct {
07  struct S1 f0
08    }
09a[] = { 0 }
10      ;

C2 : Crashes Clang 2.6 at -O2:

01struct S0 {
02  int f0:1;
03  int f4
04}
05a;
06void
07fn1 () {
08  struct S0 b[][1][1] = { 0 };
09  b[0][0][0] = a;
10}

C3 : Crashes Clang 2.6 at -O2:

01unsigned short a;
02int b;
03char c;
04short
05fn1 () {
06  return 1 / a;
07}
08void
09fn2 () {
10  b = fn1 ();
11  char d = b;
12  c = d % 3;
13}

C4 : Crashes Clang 2.6 at -O3:

01int a, b, c, d, e;
02#pragma pack(1)
03struct S0 {
04  int f0:14;
05  int f1:13;
06  int f2:28;
07  int f3:23;
08  int f4:12
09};
10void fn1 (struct S0);
11void
12fn2 () {
13  int f;
14lbl_2311:
15  ;
16  struct S0 g = { 0, 0, 1 };
17  fn1 (g);
18  b && e;
19  for (; c;) {
20    if (d)
21      goto lbl_2311;
22    f = a && 1 ? 0 : 1;
23    g.f4 = f;
24  }
25}

C5 : Crashes Clang 2.6 at -O2:

01int crc32_context, g_2 = 0, g_5;
02int g_8;
03int *g_39, *g_371;
04int g_81;
05int func_1_l_15 ;
06static short safe_add_func_int16_t_s_s ( short si1, int si2 ) {
07    return si1 > 67 ? si1 : si1 + si2;
08  }
09 
10    static int func_1 (  ) {
11    int l_462 = 0;
12    g_2 = 0;
13    for ( ;
14  g_2 < 12;
15  g_2 = safe_add_func_int16_t_s_s ( g_2, 5 ) )     {
16       g_5 = 1;
17       for ( ;
18 g_5;
19 ++g_5 )    {
20      g_8 = 1;
21      for ( ;
22 g_8 >= 0;
23 g_8 = g_8 - 1 )        {
24          func_1_l_15 = 1;
25          for ( ;
26 func_1_l_15;
27            func_1_l_15 =   func_1_l_15  - 1         if ( g_8 )        break;
28        }
29      g_371 = &l_462;
30      int *l_128 = &g_81;
31      *l_128 = *g_39;
32    }
33 *g_371 =    0 != 0   ;
34     }
35    return 0;
36  }
37   int main (  ) {
38    func_1 (  );
39    crc32_context = g_2;
40    crc32_context += g_5;
41  }

C6 : Crashes Clang 2.6 at -O0:

01#pragma pack(1)
02struct S2 {
03  int f1;
04  short f4
05};
06struct S3 {
07  struct S2 f1;
08  int f3:14
09};
10struct {
11  struct S3 f3
12    }
13a = { 0, 0, 0 };

C7 : Crashes Clang 2.6 at -O1:

01int *a;
02static int **b;
03int c, d, e;
04void
05fn1 () {
06  d = &b == c;
07  for (;;) {
08    int **f = &a;
09    if (e) {
10    } else
11      b = f;
12    if (**b)
13      continue;
14    **f;
15  }
16}

C8 : Crashes Clang 2.6 at -O1:

01#pragma pack(1)
02struct S0 {
03  int f3;
04  char f4
05};
06struct {
07  struct S0 f6;
08  int f8
09}
10a = { 0, 0, 0 };

C9 : Crashes Clang 2.6 at -O2:

01struct S0 {
02  int f0;
03  int f1;
04  short f3;
05  int f7;
06  int f8
07}
08b;
09int a, c, d, e, f;
10void
11fn1 (struct S0 p1) {
12  d++;
13  c = p1.f8;
14  e = 0;
15  a = p1.f7;
16}
17void
18fn2 () {
19  e = 0;
20  for (; e; e++) {
21    if (d)
22      for (;;) {
23      }
24    --f;
25  }
26  fn1 (b);
27}

C10 : Crashes Clang 2.6 at -O1:

01union U2 {
02  int f0;
03  unsigned short f2
04}
05b;
06static int a = 1;
07void
08fn1 (int p1, unsigned short p2) {
09}
10int fn2 (union U2);
11union U2 fn3 ();
12static unsigned long long
13fn5 () {
14  fn1 (b.f2, b.f0);
15  return 0;
16}
17static char
18fn4 () {
19  fn5 ();
20  return 0;
21}
22int
23main () {
24  a || fn2 (fn3 (fn4 () ) );
25}

C11 : Crashes Clang 2.7 at -O1:

01int *a;
02static int **b;
03int c, d, e;
04void
05fn1 () {
06  d = &b == c;
07  for (;;) {
08    int **f = &a;
09    if (e) {
10    } else
11      b = f;
12    if (**b)
13      continue;
14    **f;
15  }
16}

C12 : Crashes Clang 2.7 at -O0:

1char a;
2unsigned char b;
3int c;
4void
5fn1 () {
6  (b ^= c) != a;
7}

C13 : Crashes Clang 2.7 at -O2:

1int a, b;
2void fn1 ();
3void
4fn2 (short p1) {
5  short c;
6  c = (65532 | 3) + p1;
7  fn1 (c && 1);
8  b = (0 == p1) * a;
9}

C14 : Crashes GCC 3.2.0 at -O1:

1void
2fn1 () {
3  struct S0 *a;
4  struct S0 *b, *c = &a;
5  struct S0 **d = &c;
6  if (&b == &a) {
7  }
8}

C15 : Crashes GCC 3.2.0 at -O3:

01volatile int a, b, c, i;
02char d;
03void
04fn1 () {
05  int e;
06  {
07    for (;; c++) {
08      int f[50] = { };
09      if (b) {
10        {
11          0;
12          {
13            {
14              int g = a, h = d;
15              e = h ? g : g / 0;
16            }
17          }
18          a = e;
19        }
20      }
21    }
22  }
23}
24void
25main () {
26  i = 0 / 0;
27  a;
28}

C16 : Crashes GCC 3.2.0 at -O3:

01int a, c;
02volatile int b;
03void
04fn1 () {
05  b;
06  for (;;)
07    break;
08  int d = b, e = a;
09  c = a ? d : d % 0;
10}
11void
12fn2 () {
13  if (0 % 0)
14    b;
15}

C17 : Crashes GCC 3.2.0 at -O2:

01union U1 {
02  int f0;
03  char f1
04};
05void
06fn1 (union U1 p1) {
07  p1.f1 = 0;
08  for (; p1.f1;) {
09  }
10}

C18 : Crashes GCC 3.2.0 at -O1:

1int a, b;
2void
3fn1 () {
4  b = 4294967290UL <= a | b;
5}

C19 : Crashes GCC 3.2.0 at -O3:

01int a, b, c;
02int
03fn1 (int p1, int p2) {
04  return p1 - p2;
05}
06void
07fn2 () {
08  int d;
09  int **e;
10  int ***f = &e;
11  d = a && b ? a : a % 0;
12  if (fn1 (f == 0, 2) )
13    c = ***f;
14}

C20 : Crashes GCC 3.3.0 at -O3:

01int a, b, d;
02struct S0 {
03  int f3
04};
05int *volatile c;
06void fn1 (struct S0);
07void
08fn2 () {
09  int e;
10  struct S0 **f;
11  struct S0 ***g = &f;
12  (a && b && b ? 0 : b) > (&c && 0);
13  e = 0 == g;
14  d = e >> 1;
15  for (;;)
16    fn1 (***g);
17}

C21 : Crashes GCC 3.4.0 at -O3:

01int a, b;
02struct U0 {
03  char f0;
04  int f2
05};
06void
07fn1 () {
08  struct U0 c;
09  for (; c.f0 != 1; c.f0 = c.f0 + a)
10    b -= 1;
11}

C22 : Crashes GCC 3.4.0 at -O3:

01int a, b, d, e;
02struct S0 {
03  int f3
04};
05int *c;
06void fn1 (struct S0);
07void
08fn2 () {
09  struct S0 **f;
10  struct S0 ***g = &f;
11  (a && b && b ? 0 : b) > (&c == d);
12  e = 1 < (0 == g);
13  for (;;)
14    fn1 (***g);
15}

C23 : Crashes GCC 4.0.0 at -O2:

1int ***a;
2int b;
3int *c;
4void
5main () {
6  if (&c == a)
7    b = 0 == *a;
8}

C24 : Crashes GCC 4.0.0 at -O2:

1int a[][0];
2int *const b = &a[0][1];
3int
4fn1 () {
5  return *b;
6}

C25 : Crashes GCC 4.0.0 at -O0:

1int a, b;
2unsigned char c;
3void
4fn1 () {
5  (0 >= a & (0 || b) ) > c;
6}

C26 : Crashes GCC 4.0.0 at -O1:

01struct {
02  int f9:1
03}
04a;
05const int b[] = { 0 };
06void fn1 ();
07void
08main () {
09  for (;;) {
10    a.f9 = b[0];
11    fn1 ();
12  }
13}

C27 : Crashes GCC 4.0.0 at -O0:

1int a, c;
2unsigned char b;
3void
4fn1 () {
5  b > (c > 0 & 0 < a);
6}

C28 : Crashes GCC 4.0.0 at -O2:

01int **a[][0];
02static int ***const b = &a[0][1];
03void fn1 ();
04int
05fn2 () {
06  return ***b;
07  fn1 ();
08}
09void
10fn1 () {
11  **b;
12}

C29 : Crashes GCC 4.1.0 at -O1:

1volatile int ***a;
2int b;
3int **c;
4void
5fn1 () {
6  if (&c == a)
7    b = 0 == *a;
8}

C30 : Crashes GCC 4.1.0 at -O1:

01struct {
02  int f0;
03  int f2
04}
05a;
06int b;
07void
08fn1 () {
09  a.f2 = 0;
10  int *c[] = { 0, 0, 0, 0, &a.f0, 0, 0, 0, &a.f0 };
11  b = *c[4];
12}

C31 : Crashes GCC 4.1.0 at -O2:

1int a, b;
2unsigned c;
3void
4fn1 () {
5  for (; c <= 0;)
6    if (b < c)
7      a = 1 && c;
8}

C32 : Crashes GCC 4.1.0 at -O1:

1unsigned a;
2int b;
3void
4main () {
5  unsigned c = 4294967295;
6  int d = c;
7  b = a <= d || a;
8}

C33 : Crashes GCC 4.1.0 at -O1:

1const volatile long a;
2void
3main () {
4  printf ("%d\n", (int) a);
5}

C34 : Crashes GCC 4.1.0 at -O3:

01int a, b;
02union U1 {
03  int f0;
04  int f1
05};
06void
07fn1 () {
08  union U1 c = { 1 };
09  int d = 1;
10  if ( (c.f1 & a ? c.f1 : 1 - a) ^ d) {
11  } else
12    b = 0;
13}

C35 : Crashes GCC 4.2.0 at -O1:

1volatile int ***a;
2int b;
3int **c;
4void
5fn1 () {
6  if (&c == a)
7    b = 0 == *a;
8}

C36 : Crashes GCC 4.2.0 at -O1:

1struct S2 {
2  volatile int f5:1;
3  int f6
4};
5static struct S2 a;
6void
7main () {
8  printf ("%d\n", a.f5);
9}

C37 : Crashes GCC 4.3.0 at -O1:

01long long *a;
02int b;
03void
04fn1 () {
05  long long **c = &a;
06  int d = 7;
07lbl_2890: {
08    long long **e = &a;
09    b = (e == c) < d;
10    d = 0;
11    goto lbl_2890;
12  }
13}

C38 : Crashes GCC 4.3.0 at -O2:

1struct S2 {
2  volatile int f5:1;
3  int f6
4};
5static struct S2 a;
6void
7main () {
8  printf ("%d\n", a.f5);
9}

C39 : Crashes GCC 4.3.0 at -O3:

01int a;
02short b;
03void
04fn1 () {
05  int c[0];
06  for (;;) {
07    a = c[0];
08    b = 0;
09    for (; b < 7; b += 1)
10      c[b] = 0;
11  }
12}

C40 : Crashes GCC 4.3.0 at -O1:

1volatile int **a;
2int *b;
3void
4fn1 () {
5  if (a == &b)
6    **a;
7}

C41 : Crashes GCC 4.3.0 at -O3:

01int a, b, c, d, e, f;
02void
03fn1 () {
04  char g;
05lbl_120:
06  if (b || e >= 0 & d >= 0 || a)
07    return;
08  g = f < 0 ? 1 : f;
09  d = g == 0 || (char) f == 0 && g == 1 ? 0 : 0 % 0;
10  if (c)
11    goto lbl_120;
12}

C42 : Crashes Intel CC 12.0.5 at -O1:

01struct U0 {
02  int f0
03}
04a;
05struct U0
06fn1 () {
07  return a;
08}
09void
10main () {
11  0 > a.f0;
12  fn1 ();
13}

C43 : Crashes Open64 4.2.4 at -O3:

01int a;
02int *b;
03unsigned c;
04void
05fn1 () {
06  for (; a; a--)
07    if (*b) {
08      c = 0;
09      for (; c >= 5; c++) {
10      }
11    }
12}

C44 : Crashes Open64 4.2.4 at -O3:

1short a;
2void
3fn1 () {
4  long b;
5  b = 44067713550;
6  a |= b;
7}

C45 : Crashes Open64 4.2.4 at -O3:

1volatile int a;
2void
3fn1 () {
4  int b = 1;
5  a || b--;
6}

C46 : Crashes Open64 4.2.4 at -O2:

01int a, b;
02void fn1 ();
03void fn2 ();
04void
05fn3 () {
06  fn2 ();
07  fn1 ();
08}
09void
10fn2 () {
11  if (1) {
12  } else
13    for (;; b++) {
14      int c = 0;
15      int *d = &a;
16      int **e = &d;
17      *e = &c;
18      *d = 0;
19      *d |= 0;
20    }
21}

C47 : Crashes Open64 4.2.4 at -O3:

01struct S0 {
02  int f1:1
03};
04int a, b;
05void
06fn1 () {
07  for (; b;) {
08    struct S0 c = { };
09    if (1) {
10      c = c;
11      a = c.f1;
12    }
13  }
14}

C48 : Crashes Open64 4.2.4 at -O3:

01int a, b;
02int
03fn1 () {
04  int *c = &b;
05  a = 0;
06  for (; a >= -26; --a) {
07    unsigned d = 18446744073709551615;
08    int *e = &b;
09    *e &= d;
10  }
11  return *c;
12}

C49 : Crashes Open64 4.2.4 at -O3:

01static int a, c, d;
02int b;
03int *e;
04void
05fn1 () {
06  for (; a; a += 1) {
07    b = 0;
08    for (; b > -16; --b)
09      for (; c;) {
10        int *f = &d;
11        *f = 0;
12      } *e = 0;
13  }
14}

C50 : Crashes Sun CC 5.11 at -xO4:

01unsigned char a, d;
02struct {
03  int f2
04}
05b;
06int c, e;
07void
08fn1 (p1) {
09}
10void
11fn2 () {
12  c = 0;
13  for (; c <= 0;)
14    e = b.f2;
15  fn1 (0);
16  b = b;
17  d = -a;
18}

C51 : Crashes Sun CC 5.11 at -fast:

01int a, c;
02int b[1];
03void
04fn1 () {
05  short d;
06  for (; a; a -= 1) {
07    d = b1 = b1;
08    b[0] = 0;
09  }
10}

C52 : Crashes Sun CC 5.11 at -xO4:

01int a, b, d;
02short c;
03int
04fn1 (p1) {
05  return a ? 0 : p1;
06}
07void
08fn2 () {
09  int e = 0;
10  for (;;) {
11    c = 0;
12    d = fn1 (e ^ ~~c);
13    d && b;
14  }
15}

C53 : Crashes Sun CC 5.11 at -fast:

01long a;
02int b, d;
03int *c;
04void
05fn1 () {
06  int *e;
07  for (;; b--)
08    for (; d;) {
09      *c = 0;
10      *c &= (&e != 1) / a;
11    }
12}

C54 : Crashes Sun CC 5.11 at -xO0:

1#pragma pack(1)
2struct {
3  int f3:1;
4  int f4:16
5}
6a = { 1, 0 };

C55 : Crashes Sun CC 5.11 at -xO3:

01int a, c;
02static int b = 1;
03void fn1 ();
04void
05fn2 () {
06  for (; a; a--) {
07    c = 0;
08    for (; c != 1;) {
09      if (b)
10        break;
11      fn1 ();
12    }
13  }
14}

C56 : Crashes Sun CC 5.11 at -xO4:

01#pragma pack(1)
02struct S0 {
03  int f1;
04  int f3:1
05}
06a;
07void
08fn1 (struct S0 p1) {
09  p1.f3 = 0;
10}
11void
12fn2 () {
13  fn1 (a);
14}

C57 : Crashes Sun CC 5.11 at -fast:

01int a, c, d, e, f, g, h, i, j, k;
02volatile int b;
03int
04fn1 () {
05  for (; d; d = a) {
06    int *l = &c;
07    c = -3;
08    for (; c > -23; --c)
09      if (k) {
10        if (*l)
11          continue;
12        return b;
13      }
14    for (; i; ++i) {
15      j = 0;
16      g = h;
17      for (; f <= 1; f += 1) {
18      }
19    }
20  }
21  return e;
22}

这篇关于红薯nbsp;57nbsp;个让nbsp;Cnbsp;编译器崩溃的代码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/596670

相关文章

SpringBoot基于MyBatis-Plus实现Lambda Query查询的示例代码

《SpringBoot基于MyBatis-Plus实现LambdaQuery查询的示例代码》MyBatis-Plus是MyBatis的增强工具,简化了数据库操作,并提高了开发效率,它提供了多种查询方... 目录引言基础环境配置依赖配置(Maven)application.yml 配置表结构设计demo_st

SpringCloud集成AlloyDB的示例代码

《SpringCloud集成AlloyDB的示例代码》AlloyDB是GoogleCloud提供的一种高度可扩展、强性能的关系型数据库服务,它兼容PostgreSQL,并提供了更快的查询性能... 目录1.AlloyDBjavascript是什么?AlloyDB 的工作原理2.搭建测试环境3.代码工程1.

Java调用Python代码的几种方法小结

《Java调用Python代码的几种方法小结》Python语言有丰富的系统管理、数据处理、统计类软件包,因此从java应用中调用Python代码的需求很常见、实用,本文介绍几种方法从java调用Pyt... 目录引言Java core使用ProcessBuilder使用Java脚本引擎总结引言python

Java中ArrayList的8种浅拷贝方式示例代码

《Java中ArrayList的8种浅拷贝方式示例代码》:本文主要介绍Java中ArrayList的8种浅拷贝方式的相关资料,讲解了Java中ArrayList的浅拷贝概念,并详细分享了八种实现浅... 目录引言什么是浅拷贝?ArrayList 浅拷贝的重要性方法一:使用构造函数方法二:使用 addAll(

JAVA利用顺序表实现“杨辉三角”的思路及代码示例

《JAVA利用顺序表实现“杨辉三角”的思路及代码示例》杨辉三角形是中国古代数学的杰出研究成果之一,是我国北宋数学家贾宪于1050年首先发现并使用的,:本文主要介绍JAVA利用顺序表实现杨辉三角的思... 目录一:“杨辉三角”题目链接二:题解代码:三:题解思路:总结一:“杨辉三角”题目链接题目链接:点击这里

SpringBoot使用注解集成Redis缓存的示例代码

《SpringBoot使用注解集成Redis缓存的示例代码》:本文主要介绍在SpringBoot中使用注解集成Redis缓存的步骤,包括添加依赖、创建相关配置类、需要缓存数据的类(Tes... 目录一、创建 Caching 配置类二、创建需要缓存数据的类三、测试方法Spring Boot 熟悉后,集成一个外

轻松掌握python的dataclass让你的代码更简洁优雅

《轻松掌握python的dataclass让你的代码更简洁优雅》本文总结了几个我在使用Python的dataclass时常用的技巧,dataclass装饰器可以帮助我们简化数据类的定义过程,包括设置默... 目录1. 传统的类定义方式2. dataclass装饰器定义类2.1. 默认值2.2. 隐藏敏感信息

opencv实现像素统计的示例代码

《opencv实现像素统计的示例代码》本文介绍了OpenCV中统计图像像素信息的常用方法和函数,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1. 统计像素值的基本信息2. 统计像素值的直方图3. 统计像素值的总和4. 统计非零像素的数量

IDEA常用插件之代码扫描SonarLint详解

《IDEA常用插件之代码扫描SonarLint详解》SonarLint是一款用于代码扫描的插件,可以帮助查找隐藏的bug,下载并安装插件后,右键点击项目并选择“Analyze”、“Analyzewit... 目录SonajavascriptrLint 查找隐藏的bug下载安装插件扫描代码查看结果总结Sona

Python开发围棋游戏的实例代码(实现全部功能)

《Python开发围棋游戏的实例代码(实现全部功能)》围棋是一种古老而复杂的策略棋类游戏,起源于中国,已有超过2500年的历史,本文介绍了如何用Python开发一个简单的围棋游戏,实例代码涵盖了游戏的... 目录1. 围棋游戏概述1.1 游戏规则1.2 游戏设计思路2. 环境准备3. 创建棋盘3.1 棋盘类