Skip site navigation (1)Skip section navigation (2)
Date:      20 Dec 2002 21:24:39 -0500
From:      Joe Marcus Clarke <marcus@marcuscom.com>
To:        current@freebsd.org
Subject:   WEIRD! div() broken on -CURRENT?
Message-ID:  <1040437478.29101.23.camel@shumai.marcuscom.com>

next in thread | raw e-mail | index | archive | help

--=-3yZhQdDsV/2so3ycgHnv
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Okay, I must be losing my mind.  Does anyone know why the following
program compiled with stock gcc-3.2.1, stock CFLAGS, and no CPUTYPE
produces:

ddy.quot =3D 1
ddy.rem =3D -1077937744

on -CURRENT, and:

ddy.quot =3D 8
ddy.rem =3D 0

On -stable?

#include <stdlib.h>
#include <stdio.h>

main(void) {
    div_t ddy;
    int dy, dy_frac;

    ddy =3D div (768, 96);
    dy =3D ddy.quot;
    dy_frac =3D ddy.rem;

    printf("ddy.quot =3D %d\n", dy);
    printf("ddy.rem =3D %d\n", dy_frac);

    return 0;
}

> cc -O -pipe -o xxx xxx.c

I'm doing something wrong, right?  I mean, this can't be right.  I've
verified this now on a P4 running:

FreeBSD jclarke-pc.cisco.com 5.0-RC FreeBSD 5.0-RC #0: Mon Dec 16
02:54:55 EST 2002   =20
marcus@jclarke-pc.cisco.com:/usr/obj/usr/src/sys/JCLARKE-PC  i386

And a PIII running:

FreeBSD sysinfo.mezzweb.com 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Mon Dec
16 09:44:28 CST 2002   =20
root@sysinfo.mezzweb.com:/usr/src/sys/i386/compile/BSDROCKS  i386

Both machines produce the same result, while my -stable machines produce
the correct result.  Both machines have fresh -CURRENT headers.  Oh, and
if I move the xxx binary from my -stable machine to my -CURRENT machine,
it produces the correct result.  Both machines have WITNESS and
INVARIANTS disabled.  The PIII has MATH_EMULATE compiled in, but the P4
does not.  Any help would be most appreciated as I think this is causing
Nautilus crashes on -CURRENT.  Thanks.

Joe

--=20
PGP Key : http://www.marcuscom.com/pgp.asc

--=-3yZhQdDsV/2so3ycgHnv
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQA+A9Dmb2iPiv4Uz4cRAnhbAKCMNuyAM9FhZGQsyMaZjNMiDEn2PgCfSlZn
wAjQe/YSguti6SEFcFMfiNE=
=O6Ak
-----END PGP SIGNATURE-----

--=-3yZhQdDsV/2so3ycgHnv--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1040437478.29101.23.camel>