From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,86b52dc0e0192a3e,start X-Google-Attributes: gidfee84,public From: wcwang@hagen.psych.indiana.edu (Bill Wang) Subject: cc -O3 problem on osf v3.2 Date: 1995/06/28 Message-ID: <3srrb4$qhe@usenet.ucs.indiana.edu>#1/1 X-Deja-AN: 105263112 organization: Indiana University newsgroups: comp.unix.osf.osf1 The following short c program produces two different result by using -O3 and -O (or no optimization at all): #include #include 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