home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / gcc / bug / 3076 < prev    next >
Encoding:
Text File  |  1992-12-30  |  2.9 KB  |  97 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!mtholyoke.EDU!jbotz
  3. From: jbotz@mtholyoke.EDU (Jurgen Botz)
  4. Subject: Re: Bug in gcc-2.3.3 found while compiling Tk-3.0
  5. Message-ID: <C011y6.8D4@mtholyoke.edu>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Mount Holyoke College
  8. References: <BzzHI7.HIr@mtholyoke.edu>
  9. Distribution: gnu
  10. Date: Tue, 29 Dec 1992 15:34:53 GMT
  11. Approved: bug-gcc@prep.ai.mit.edu
  12. Lines: 83
  13.  
  14. In article <BzzHI7.HIr@mtholyoke.edu> I reported a bug in gcc-2.3.3, but
  15. I was advised by rms that my bug report did not contain enough information
  16. to be useful.  Sorry about that... I submitted it after having not gotten
  17. any sleep in over 30 hours and I was a little out of it.  Here's a more
  18. detailed report with a self contained example (extracted from Tk3.0 by
  19. John Ousterhout, available from sprite.berkeley.edu)
  20.  
  21. gcc is version 2.3.3, built on a DECstation 3100 under Ultrix 4.2 with
  22. "configure mips-dec-ultrix".  The version used was installed from the
  23. third stage compilation.
  24.  
  25. Compiling the included example with optimization ("gcc -O -c test.c")
  26. produces the following error message:
  27.  
  28.    test.c: In function 'TkBezierScreenPoint':
  29.    test.c:54: fp_offset (16) or end_offset (-4) is less than zero.
  30.  
  31. Compiling the same file with gcc 2.3.2 ("gcc -V 2.3.2 -O -c test.c")
  32. or with gcc 2.3.3 without optimization produces no error.  Brief
  33. testing of Tk-3.0 with tkTrig.c compiled with 2.3.2 and everything
  34. else with 2.3.3 (optimization on in both cases) seems to indicate that
  35. 2.3.2 compiles and optimizes this function correctly.
  36.  
  37. - Jurgen Botz, jbotz@mtholyoke.edu
  38.  
  39. --------- snip ----------------------------------------------------
  40.  
  41. /*
  42. ** Excerpt from tkTrig.c, tkCanvas.h & Xlib.h
  43. **
  44. ** Tk is copyright 91, 92, Regents of the Univ. of California
  45. */
  46.  
  47. typedef struct {
  48.     short x, y;
  49. } XPoint;
  50.  
  51. #define SCREEN_X(canvasPtr, x) \
  52.     (((int) ((x) + 0.5)) - (canvasPtr)->drawableXOrigin)
  53. #define SCREEN_Y(canvasPtr, y) \
  54.     (((int) ((y) + 0.5)) - (canvasPtr)->drawableYOrigin)
  55.  
  56. typedef struct {
  57.     /* ... */
  58.     int drawableXOrigin, drawableYOrigin;
  59.     /* ... */
  60. } Tk_Canvas;
  61.  
  62.  
  63. void
  64. TkBezierScreenPoints(canvasPtr, control, numSteps, xPointPtr)
  65.     Tk_Canvas *canvasPtr;        /* Canvas in which curve is to be
  66.                      * drawn. */
  67.     double control[];            /* Array of coordinates for four
  68.                      * control points:  x0, y0, x1, y1,
  69.                      * ... x3 y3. */
  70.     int numSteps;            /* Number of curve points to
  71.                      * generate.  */
  72.     register XPoint *xPointPtr;        /* Where to put new points. */
  73. {
  74.     int i;
  75.     double u, u2, u3, t, t2, t3;
  76.  
  77.     for (i = 1; i <= numSteps; i++, xPointPtr++) {
  78.     t = ((double) i)/((double) numSteps);
  79.     t2 = t*t;
  80.     t3 = t2*t;
  81.     u = 1.0 - t;
  82.     u2 = u*u;
  83.     u3 = u2*u;
  84.     xPointPtr->x = SCREEN_X(canvasPtr, (control[0]*u3
  85.         + 3.0 * (control[2]*t*u2 + control[4]*t2*u) + control[6]*t3));
  86.     xPointPtr->y = SCREEN_Y(canvasPtr, (control[1]*u3
  87.         + 3.0 * (control[3]*t*u2 + control[5]*t2*u) + control[7]*t3));
  88.     }
  89. }
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.