Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: wcwang@hagen.psych.indiana.edu (Bill Wang)
Subject: cc -O3 problem on osf v3.2
Date: 1995/06/28	[thread overview]
Message-ID: <3srrb4$qhe@usenet.ucs.indiana.edu> (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



             reply	other threads:[~1995-06-28  4:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-06-28  4:00 Bill Wang [this message]
1995-06-28  4:00 ` cc -O3 problem on osf v3.2 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
read-only archive

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