Oh Dear

Michiel Helvensteijn m.helvensteijn.remove at gmail.com
Sun Jul 12 02:02:40 PDT 2009


Walter Bright wrote:

>> In other words, every bug in DMD is really a feature of the language.
>> Until you fix it. That kind of permanent instability may be part of the
>> reason people have been so negative around here lately.
> 
> I don't agree with that characterization. Bugs get reported to bugzilla,
> and get fixed in a regular cycle.

Sure they do. But if it's really true that the DMD implementation *is* the D
language specification, any bug in DMD would also be part of that
specification. And as the compiler changes, so does the spec. It's the
danger of that approach.

>> I will file those corrections.
> 
> Thank you, I look forward to it.

Issue 3165, Issue 3166.

>> By the way, what kind of integer division *does* D use?
> 
> To be frank, it is what the x86 DIV instruction does.

After a quick Google search, it would seem DIV is the x86 "unsigned divide"
instruction. Are you sure you aren't using IDIV ("signed divide") for
negative operands? If not, you'd actually be interpreting 2's complement
signed ints as unsigned ints. (And surely such a thing would have been
noticed before now?)

> But I agree that 
> the modulus should be defined, regardless of whether that makes it less
> efficient on some machines.

Good. Make sure that your divide operation and your modulo operation are
consistent. The following identity should hold:

if  a / n = q
and a % n = r

a = q*n + r

-- 
Michiel Helvensteijn




More information about the Digitalmars-d mailing list