Unix Technical Forum

Re: more improvements for mg

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 ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 07:50 AM
Han Boetes
 
Posts: n/a
Default Re: more improvements for mg

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:11 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com