Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* cc -O3 problem on osf v3.2
@ 1995-06-28  4:00 Bill Wang
  1995-06-28  4:00 ` Dan Pop
  1995-07-03  4:00 ` f77 and cc optimization " Christos Siopis
  0 siblings, 2 replies; 5+ messages in thread
From: Bill Wang @ 1995-06-28  4:00 UTC (permalink / raw)


The following short c program produces two different result by
using -O3 and -O (or no optimization at all):

#include <stdio.h>
#include <math.h>

main() {
     double sig( double x, double gain, double thresh);
     double x;
     for (x=(-4.0); x<4.1; x+=1.0) {
          printf("%f %f\n", x, sig(x,1.0,0.0) );
     }
}

double sig( double x, double gain, double thresh) {
     return( 1.0 / ( 1.0 + exp( - (gain) * ( x - thresh ) ) ) );
}


Using -O or no opti: (correct result, same result on SUN, HP, Ultrix, etc)

-4.000000 0.017986
-3.000000 0.047426
-2.000000 0.119203
-1.000000 0.268941
0.000000 0.500000
1.000000 0.731059
2.000000 0.880797
3.000000 0.952574
4.000000 0.982014

Using -O3:	(WRONG!)

-4.000000 0.982014
-3.000000 0.952574
-2.000000 0.880797
-1.000000 0.731059
0.000000 0.500000
1.000000 0.268941
2.000000 0.119203
3.000000 0.047426
4.000000 0.017986

Any hints or help would be appreciated!

-- 
Bill Wang
US Mail = Psychology Department, Indiana University, Bloomington, IN 47405
Internet = wcwang@cs.indiana.edu
HTTP =  http://www.psych.indiana.edu/hyplan/wcwang.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1995-07-03  4:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-06-28  4:00 cc -O3 problem on osf v3.2 Bill Wang
1995-06-28  4:00 ` Dan Pop
1995-06-29  4:00   ` Mike Iglesias
1995-07-03  4:00 ` f77 and cc optimization " Christos Siopis
1995-07-03  4:00   ` Dan Pop

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox