2
0

dggccbug.c 962 B

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