1 /* NOCW */ 2 /* dggccbug.c */ 3 /* bug found by Eric Young (eay@cryptsoft.com) - May 1995 */ 4 5 #include <stdio.h> 6 7 /* 8 * There is a bug in gcc version 2.5.8 (88open OCS/BCS, DG-2.5.8.3, Oct 14 9 * 1994) as shipped with DGUX 5.4R3.10 that can be bypassed by defining 10 * DG_GCC_BUG in my code. The bug manifests itself by the vaule of a pointer 11 * that is used only by reference, not having it's value change when it is 12 * used to check for exiting the loop. Probably caused by there being 2 13 * copies of the valiable, one in a register and one being an address that is 14 * passed. 15 */ 16 17 /*- 18 * compare the out put from 19 * gcc dggccbug.c; ./a.out 20 * and 21 * gcc -O dggccbug.c; ./a.out 22 * compile with -DFIXBUG to remove the bug when optimising. 23 */ 24 25 void inc(a) 26 int *a; 27 { 28 (*a)++; 29 } 30 31 main() 32 { 33 int p = 0; 34 #ifdef FIXBUG 35 int dummy; 36 #endif 37 38 while (p < 3) { 39 fprintf(stderr, "%08X\n", p); 40 inc(&p); 41 #ifdef FIXBUG 42 dummy += p; 43 #endif 44 } 45 } 46