Why is it that no one writes with portability in mind in druntime?
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Mon Nov 25 01:40:11 PST 2013
On 25/11/13 09:52, Jonathan M Davis wrote:
> Yes, they're aliases, but you have to worry about them. Take this code for
> instance.
>
> int len = arr.length;
>
> That code will compile as 32-bit, but it will _not_ compile as 64-bit, because
> length is size_t, which on 32-bit systems happens to be uint, which implicitly
> converts to int, whereas on 64-bit systems, it's ulong, which does _not_
> implicitly convert to it.
You're quite right -- I was just thinking about underlying stuff along the lines
of what Iain was pointing out for real, not "user-land" cases like this.
To be honest, I assumed that anyone with any experience or common sense would
understand stuff like the example you've described, and not write such code.
But that's probably very very naive ... :-)
The size_t case I rather like to think of is:
size_t m = ...;
size_t p = 1 << m; // should this be 1U, 1UL ... ?
More information about the Digitalmars-d
mailing list