bearophile can say "i told you so" (re uint->int implicit conv)
Benjamin Thaut
code at benjamin-thaut.de
Fri Mar 29 12:38:32 PDT 2013
Am 29.03.2013 20:29, schrieb Jonathan M Davis:
> No. -w makes it so that warnings are errors, so you generally can't make
> anything a warning unless you're willing for it to be treated as an error at
> least some of the time (and a lot of people compile with -w), and this sort of
> thing is _supposed_ to work without a warning - primarily because if it
> doesn't, you're forced to cast all over the place when you're dealing with
> both signed and unsigned types, and the casts actually make your code more
> error-prone, because you could end up casting something other than uint to int
> or int to uint by accident (e.g. long to uint) and end up with bugs due to
> that.
Reading this tells me two things:
1) The D-Cast is seriously broken, the default behavior should not be
one that "breaks" stuff if you don't use it right. I personally really
like the idea of having different types of casts. Some of which still
doe checks and other that just do what you want because you know what yu
are doing.
2) The library needs something like an int_cast which checks casts from
one integer type to another and asserts / throws on error. (For an
example see
https://github.com/Ingrater/thBase/blob/master/src/thBase/casts.d#L28)
Kind Regards
Benjamin Thaut
More information about the Digitalmars-d
mailing list