This is a discussion on Re: more improvements for mg within the mailing.openbsd.tech forums, part of the OpenBSD category; --> Zvezdan Petkovic wrote: > On Mon, May 16, 2005 at 09:59:04AM -0600, Todd C. Miller wrote: > > While ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Zvezdan Petkovic wrote: > On Mon, May 16, 2005 at 09:59:04AM -0600, Todd C. Miller wrote: > > While this does look OK I really don't see the need for the > > cast to size_t. In practice sizeof(foo) will not be > INT_MAX > > unless you are creating 2GB data structures on the stack and > > the stack is not big enough to hold such a data structure > > anyway. > > I agree that cast is not necessary since even lint doesn't > complain about it. It doesn't hurt to have the cast either, > since that cast _will_ happen implicitly anyway. In the above > program it doesn't matter since a positive number has a 0 for > the most significant bit and remains the same when cast to > unsigned. > > If sizeof returns size_t, and size_t is typedefed as unsigned > int, according to the implicit expression casting rules, int > _will_ be cast into unsigned when compared to an unsigned > number. Fascinating stuff. I googled a bit for implicit casting and I found this: http://www.peroxide.dk/download/tuto.../chapter6.html Which goes a bit deeper into the subject. # Han |