disabling unary "-" for unsigned types

Brad Roberts braddr at bellevue.puremagic.com
Tue Feb 16 11:20:18 PST 2010


On Tue, 16 Feb 2010, dsimcha wrote:

> I **HATE** this example because it's a classic example of extreme nitpicking.  On
> most modern computers, (void*).sizeof == size_t.sizeof.  Furthermore, usually half
> your address space is reserved for kernel use.  Therefore, this bug would only
> show up when you're searching an array of bytes **and** very close to exhausting
> available address space (i.e. when you probably have bigger problems anyhow).  I
> have intentionally written binary searches like this even though I'm aware of this
> bug because it's more readable and efficient than doing it "right" and would only
> fail in corner cases too extreme to be worth considering.

Actually, linux has used the 3:1 split for as long as I can recall.  That 
leads to easilly allowing this case to hit.  I've seen it hit in real 
world apps.  I agree that when you're playing in that neighborhood that 
you should consider moving to 64 bit apps, but there's downsides there 
too.  64bit addressing isn't a silver bullet,  unfortunatly.  Any app 
that's integer or pointer heavy in its data structures pays a big cost.

Later,
Brad




More information about the Digitalmars-d mailing list