Signed word lengths and indexes

Justin Spahr-Summers Justin.SpahrSummers at gmail.com
Wed Jun 16 23:56:52 PDT 2010


On Thu, 17 Jun 2010 02:46:13 -0400, Kagamin <spam at here.lot> wrote:
> 
> Walter Bright Wrote:
> 
> > Easy. offset should be a size_t, not an unsigned.
> 
> I've hit the bug using size_t at the right side of a+=-b (array length). It's just a long was at the left side (file offset). Such code should actually work in 64bit system and it fails in 32bit. MS compiler reports such portability issues with a warning, I believe.

This sounds more like an issue with file offsets being longs, 
ironically. Using longs to represent zero-based locations in a file is 
extremely unsafe. Such usages should really be restricted to short-range 
offsets from the current file position, and fpos_t used for everything 
else (which is assumably available in std.c.stdio).


More information about the Digitalmars-d mailing list