Thread View: comp.bugs.sys5
2 messages
2 total messages
Started by Ted H. Emigh
Mon, 22 Jun 1987 20:19
Possible Bug in fpcc Release 1.0
Author: Ted H. Emigh
Date: Mon, 22 Jun 1987 20:19
Date: Mon, 22 Jun 1987 20:19
64 lines
2799 bytes
2799 bytes
I am trying to get the following segment of code to compile under
fpcc Release 1.0 (12/2/85 -- as far as I can tell, the current release)
on an AT&T 3B2/400 with SVR3.0. This code comes from a larger package
and I have pared it down somewhat. For the comp.lang.c folks -- is this
valid C code? (The person I got this from assures me that it has compiled
under a variety of compilers, systems, etc.). Of course, I have sent it
through lint and it "passes", and I have been able to compile it on the
unix-pc (SVR1+) Version 3.5 (we don't have cc on the 3B2). The error
messages I receive follow the program:
---------------------------Start of program---------------------------------
#include <stdio.h>
main ()
{
printf("Random number is: %i\n",randbin(10,1,2));
}
/* FUNCTION randbin: return a random binomial number */
/* N is the number of trials; The probability of success is p = p1/p2 */
int
randbin (N, p1, p2)
register
int N; /* Number of trials */
int p1, p2; /* p = p1/p2 */
{
double p = (double) p1 / (double) p2;
int r = 0; /* number of successes */
double chk;
while (N-- > 0)
{
chk = rand () / (double) 32767.0;
if (chk < p)
r++;
printf("%i %g %g %i \n",N,p,chk,r);
}
return (r);
}
-------------------------------------End of program-------------------------
Now for the errors:
If I compile it without optimization (fpcc -o test test.c) it compiles
and runs perfectly. If I compile it with optimization (fpcc -O -o test test.c)
I get the following error message:
Assembler: work.c
aline 37 : operand type mismatch
... operand #2 of "mmovwd": "%r7"
aline 39 : operand type mismatch
... operand #1 of "mfdivd3": "%r7"
As far as I can tell, it is choking on
double p = (double) p1 / (double) p2;
Is this a bug in fpcc? Is there any way around it? I hate to use unoptimized
code as this function can be called often during some calculation intensive
situations.
--Ted--
--
Ted H. Emigh, Systems NonAdministrator,Genetics, NCSU, Raleigh, NC
uucp: mcnc!ncsuvx!ncsugn!emigh internet: emigh%ncsugn.ncsu.edu
BITNET: NEMIGH@TUCC @ncsuvx.ncsu.edu:emigh@ncsugn.ncsu.edu
Re: Possible Bug in fpcc Release 1.0
Author: Doug Gwyn
Date: Tue, 23 Jun 1987 17:23
Date: Tue, 23 Jun 1987 17:23
13 lines
1251 bytes
1251 bytes
In article <471@ncsugn.ncsu.edu> emigh@ncsugn.UUCP (Ted H. Emigh) writes: > aline 37 : operand type mismatch > ... operand #2 of "mmovwd": "%r7" > aline 39 : operand type mismatch > ... operand #1 of "mfdivd3": "%r7" One quite often encounters this type of error introduced into previously valid code by so-called "optimizers". It's definitely a bug in the C optimizer, perhaps due to an improper template somewhere. (Also see if the M32 SGS optimixer* bug fixes I posted to comp.bugs.sys5 a couple of months ago (as DMD SGS bugs) have been installed.) *This was a typo, but it seemed too fortuitous to correct!
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads