opEquals/opCmp returning other types
Simen Kjærås
simen.kjaras at gmail.com
Mon Mar 19 16:29:17 PDT 2012
On Mon, 19 Mar 2012 18:28:00 +0100, Simen Kjærås <simen.kjaras at gmail.com>
wrote:
> On Mon, 19 Mar 2012 09:29:34 +0100, Timon Gehr <timon.gehr at gmx.ch> wrote:
>
>> The current limitations make it impossible to define (for example) a
>> floating point type with NaN that behaves like built-in
>> float/double/real.
>
> As it turns out, this is possible. opCmp can return a float, and
> things work just fine (!<, !>=, etc). The problem appears with
> opEquals.
>
> This is the generated assembly:
>
> fldz
> fucompp
> fnstsw ax
> sahf
> jne <somewhere>
>
> So it compares the result to 0.0, copies status flags to the CPU,
> then checks if any of the flags are set. If the returned value *is*
> equal to 0.0, the C3 flag is set. The result is that the jump is
> taken only when the returned value is *less* than 0.0. I have a
> feeling this is wrong. Should I file this in BugZilla?
I went ahead and filed it:
http://d.puremagic.com/issues/show_bug.cgi?id=7734
More information about the Digitalmars-d
mailing list