红薯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

相关文章

Java集合之Iterator迭代器实现代码解析

《Java集合之Iterator迭代器实现代码解析》迭代器Iterator是Java集合框架中的一个核心接口,位于java.util包下,它定义了一种标准的元素访问机制,为各种集合类型提供了一种统一的... 目录一、什么是Iterator二、Iterator的核心方法三、基本使用示例四、Iterator的工

Java 线程池+分布式实现代码

《Java线程池+分布式实现代码》在Java开发中,池通过预先创建并管理一定数量的资源,避免频繁创建和销毁资源带来的性能开销,从而提高系统效率,:本文主要介绍Java线程池+分布式实现代码,需要... 目录1. 线程池1.1 自定义线程池实现1.1.1 线程池核心1.1.2 代码示例1.2 总结流程2. J

JS纯前端实现浏览器语音播报、朗读功能的完整代码

《JS纯前端实现浏览器语音播报、朗读功能的完整代码》在现代互联网的发展中,语音技术正逐渐成为改变用户体验的重要一环,下面:本文主要介绍JS纯前端实现浏览器语音播报、朗读功能的相关资料,文中通过代码... 目录一、朗读单条文本:① 语音自选参数,按钮控制语音:② 效果图:二、朗读多条文本:① 语音有默认值:②

Vue实现路由守卫的示例代码

《Vue实现路由守卫的示例代码》Vue路由守卫是控制页面导航的钩子函数,主要用于鉴权、数据预加载等场景,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着... 目录一、概念二、类型三、实战一、概念路由守卫(Navigation Guards)本质上就是 在路

uni-app小程序项目中实现前端图片压缩实现方式(附详细代码)

《uni-app小程序项目中实现前端图片压缩实现方式(附详细代码)》在uni-app开发中,文件上传和图片处理是很常见的需求,但也经常会遇到各种问题,下面:本文主要介绍uni-app小程序项目中实... 目录方式一:使用<canvas>实现图片压缩(推荐,兼容性好)示例代码(小程序平台):方式二:使用uni

JAVA实现Token自动续期机制的示例代码

《JAVA实现Token自动续期机制的示例代码》本文主要介绍了JAVA实现Token自动续期机制的示例代码,通过动态调整会话生命周期平衡安全性与用户体验,解决固定有效期Token带来的风险与不便,感兴... 目录1. 固定有效期Token的内在局限性2. 自动续期机制:兼顾安全与体验的解决方案3. 总结PS

C#中通过Response.Headers设置自定义参数的代码示例

《C#中通过Response.Headers设置自定义参数的代码示例》:本文主要介绍C#中通过Response.Headers设置自定义响应头的方法,涵盖基础添加、安全校验、生产实践及调试技巧,强... 目录一、基础设置方法1. 直接添加自定义头2. 批量设置模式二、高级配置技巧1. 安全校验机制2. 类型

Python屏幕抓取和录制的详细代码示例

《Python屏幕抓取和录制的详细代码示例》随着现代计算机性能的提高和网络速度的加快,越来越多的用户需要对他们的屏幕进行录制,:本文主要介绍Python屏幕抓取和录制的相关资料,需要的朋友可以参考... 目录一、常用 python 屏幕抓取库二、pyautogui 截屏示例三、mss 高性能截图四、Pill

使用MapStruct实现Java对象映射的示例代码

《使用MapStruct实现Java对象映射的示例代码》本文主要介绍了使用MapStruct实现Java对象映射的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,... 目录一、什么是 MapStruct?二、实战演练:三步集成 MapStruct第一步:添加 Mave

Java抽象类Abstract Class示例代码详解

《Java抽象类AbstractClass示例代码详解》Java中的抽象类(AbstractClass)是面向对象编程中的重要概念,它通过abstract关键字声明,用于定义一组相关类的公共行为和属... 目录一、抽象类的定义1. 语法格式2. 核心特征二、抽象类的核心用途1. 定义公共接口2. 提供默认实