[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Looking for a temporary account on Alpha



On Sun, Feb 25, 2007 at 09:33:08PM +0100, Frank B. Brokken wrote:
> Dear Steve Langasek, you wrote:
> 
> > > The intention here is to use size_t in situations where the value is known
> > > to be non-negative.
> > 
> > I don't see any reason why you should use size_t for that instead of
> > unsigned int.  size_t is intended for use in describing the size of objects
> > in memory, not just for anything you know should be non-negative.
> 
> Hm, well, your observation is interesting, but I'm not convinced:
> 
> https://www.securecoding.cert.org/confluence/display/seccode/INT01-A.+Use+size_t+for+all+integer+values+representing+the+size+of+an+object
> 
[...]

They're all talking about sizes and arrays and things like that.  Things
were you run into problems because for instance your index can't represent
all the values it needs too.

Anyway, the problem is that it's not always using size_t.  You can't go
and use an int in one fuction, and then use a size_t in another function
for the same thing, and hope that you don't run into problems.

The compiler probably generated a warning or error about the type
mismatch.  And then it was ignored by explictly casting it so the types
match.  You should be careful when doing casts, and that wasn't a good
place to do one.


Kurt



Reply to: