delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/12/08/16:57:30

To: ESCHN705 AT RZ DOT Braunschweig DOT PTB DOT DBP DOT de
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu, bug-gcc AT prep DOT ai DOT mit DOT edu
Subject: Re: -O and -O2
Date: Tue, 08 Dec 92 10:58:04 PST
From: Jonathan Ryshpan <jon AT halsp DOT hitachi DOT com>

The following was posted to the djgpp mailing list by 
	ESCHN705 AT RZ DOT Braunschweig DOT PTB DOT DBP DOT de
I tried it using gcc 2.2.2, running under Iteractive Unix version 2.2.
It produces errors of essentially the same kind as ESCHN705 reported.

When compiled with option -O it produces (the program is named fail.c):
$ fail
 0 Bus error

When compiled with option -O2 it produces:
$ fail
 0  1 Bus error

This looks like a bug in gcc; but I don't have time to do more than
report it.

/*-----------------------------------------------------------------------*/
/*  I'm in trouble with 1.08.                                            */
/*  Below you find a program test.c, that works, when it is compiled     */
/*  with                                                                 */
/*  gcc -Wall test.c -lm                                                 */
/*  or with TurboC.                                                      */
/*                                                                       */
/*  When compiled with                                                   */
/*  gcc -Wall -O2 test.c -lm                                             */
/*  or                                                                   */
/*  gcc -Wall -O test.c -lm                                              */
/*  it fails, giving an exception 14 from different points.              */
/*  I'm not able to figure out, what's wrong.                            */
/*  Can anybody help me?                                                 */
/*                                                                       */
/*  test.c:                                                              */
/*-----------------------------------------------------------------------*/
#include <stdio.h>
#include <math.h>

#define maxdim 23

typedef double matrix[2*maxdim+1][2*maxdim+1];

void main (argc,argv)

int argc;
char **argv;

{  matrix morg;
   int lact, lm, ln;
   double alpha1, alpha2, alpha3;

   alpha1 = 2; alpha2 = 3; alpha3=4;

   for (lact=0; lact <= maxdim; ++lact)
     { printf("%2d ",lact); fflush(stdout);
       for (lm=0; lm <= 2*lact; ++lm)
         for (ln=0; ln <= 2*lact; ++ln) morg[lm][ln] = 0;

       for (lm=0; lm <= lact; ++lm)
         { morg[lm][lm] =
           morg[2*lact-lm][2*lact-lm] =
             -0.5*((2*lm+1)*lact-lm*lm)*(alpha1+alpha2) -
             (lact-lm)*(lact-lm)*alpha3;
           morg[lm][2+lm] = morg[2+lm][lm] =
           morg[2*lact-lm][2*(lact-1)-lm] = morg[2*(lact-1)-lm][2*lact-lm] =
             -0.25*sqrt((lm+1.0)*(lm+2.0)*(2.0*lact-lm)*(2.0*lact-1.0-lm));
         }
     }
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019