Date: Thu, 15 Nov 2007 17:20:02 +1100 From: Peter Jeremy <peterjeremy@optushome.com.au> To: Pete French <petefrench@ticketswitch.com> Cc: stable@freebsd.org Subject: Re: Float problen running i386 inary on amd64 Message-ID: <20071115062002.GK89746@server.vk2pj.dyndns.org> In-Reply-To: <E1Io4dE-0001eQ-8X@dilbert.ticketswitch.com> References: <E1Io4dE-0001eQ-8X@dilbert.ticketswitch.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Fri, Nov 02, 2007 at 10:04:48PM +0000, Pete French wrote:
> int
> main(int argc, char *argv[])
> {
> if(atof("3.2") == atof("3.200"))
> puts("They are equal");
> else
> puts("They are NOT equal!");
> return 0;
> }
Since the program as defined above does not include any prototype for
atof(), its return value is assumed to be int. The i386 code for the
comparison is therefore:
movl $.LC0, (%esp)
call atof
movl $.LC1, (%esp)
movl %eax, %ebx
call atof
cmpl %eax, %ebx
je .L7
Note that this is comparing the %eax returned by each atof(). Since
atof() actually returns a double in %st(0) and %eax is a scratch
register, the results are completely undefined. Unfortunately, I
can't explain why an i386 would be different to an amd64 in i386 mode.
--
Peter Jeremy
Please excuse any delays as the result of my ISP's inability to implement
an MTA that is either RFC2821-compliant or matches their claimed behaviour.
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)
iD8DBQFHO+US/opHv/APuIcRAqtpAJ9ZxueKvs5Vs9UlwTIT1SBe1RzAsgCgiYTD
q5pX6Hcxx6U1EVJn6VphecU=
=PcA5
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071115062002.GK89746>
