Matrix creation quiz
bearophile
bearophileHUGS at lycos.com
Thu Apr 28 09:46:14 PDT 2011
Pedro Rodrigues:
> The fact that 'i' and 'j' are deduced to type 'uint' in the second
> version. That's the kind of bug that would keep me up at night.
Almost right answer. i and j are size_t, that is not uint in 64 bit compilations. Unsigned numbers cause the (i-j) sub-expression to give wrong results.
------------------------
Moritz Warning:
> I wonder, can there be done smth. on behalf of the language to prevent
> this kind of bug?
Two possible solutions, both refused by Walter:
- Dmd may use signed word for array indexes and lenghts.
- dmd may introduce runtime overflows.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list