20020423-1.c

来自「Mac OS X 10.4.9 for x86 Source Code gcc」· C语言 代码 · 共 34 行

C
34
字号
/* PR c/5430 *//* Verify that the multiplicative folding code is not fooled   by the mix between signed variables and unsigned constants. */extern void abort (void);extern void exit (int);int main (void){  int my_int = 924;  unsigned int result;  result = ((my_int*2 + 4) - 8U) / 2;  if (result != 922U)    abort();           result = ((my_int*2 - 4U) + 2) / 2;  if (result != 923U)    abort();  result = (((my_int + 2) * 2) - 8U - 4) / 2;  if (result != 920U)    abort();  result = (((my_int + 2) * 2) - (8U + 4)) / 2;  if (result != 920U)    abort();  result = ((my_int*4 + 2U) - 4U) / 2;  if (result != 1847U)    abort();  exit(0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?