[net.unix-wizards] bug related to "cc -p" on SUN's

jwf@vaxine.UUCP (Jim Franklin) (08/01/85)

There is a bug related to the C profiler switch (i.e., cc -p) on
SUN Microsystems 4.2BSD systems.  Take the following C program
and call it "junk.c".

main ()
{
        int i, j;

        i = -2147483648;
        j = i / 10;
        printf ("%d\n", j);
}

Then do the following on your SUN:

        > cc junk.c -o junk
        > junk
        -214748364                      (right)
        > cc -p junk.c -o junk
        > junk
        214748364                       (oops)

We are running 4.2BSD, SUN version 1.2.  This works fine on our VAXen.
I looked at the .s files for the profiled and normal compile, the only
difference is the mcount call.  The SUN compiler calls ldivt() to do the
integer divide.  I suspect that the problem is in the ldivt() you get
from the profiling version of libc.a (/usr/lib/libc_p.a).